我搜索了一段时间,试图找出是否有类似的问题,但不能。
如何将class Piece(object):
def __init__(self, x , y):
self.x = x
self.y = y
def move(self, amount, direction):
if direction == 'right':
self.x = self.x + amount
if direction == 'left':
self.x = self.x - amount
if direction == 'up':
self.y = self.y + amount
if direction == 'down':
self.y = self.y - amount
rook = Piece(0,0)
piece = input('What piece would you like to move?')
#Assume that the user types rook after this prompt
piece.move(4,'right')
(从VC ++)转换为System::String^
(来自OpenCV)?
cv::String
给出错误
double x, y;
x = 10;
y = 10;
System::String ^ displayString = System::String::Concat("( ", x, " , ", y, " )");
char * test1 = displayString->ToCharArray;
cv::String test = cv::String(test1)
将Severity Code Description Project File Line Suppression State
Error C3867 'System::String::ToCharArray': non-standard syntax; use '&' to create a pointer to member RobocopComputerVision RobocopComputerVision .cpp 156
转换为System::String^
的最佳方式是什么?
答案 0 :(得分:0)
试试这个,
#include <msclr\marshal_cppstd.h>
using namespace msclr::interop;
/* ... ... */
System::String ^ displayString = System::String::Concat("( ", x, " , ", y,")");
cv::String test = marshal_as<std::string>(displayString);