这是我在 Visual C++ Express 2010 中处理的一个类的标题:
/* custom class header to communicate with LynxMotion robot arm */
#include <vector>
using namespace System;
using namespace System::IO::Ports;
public ref class LynxRobotArm
{
public:
LynxRobotArm();
~LynxRobotArm();
void connectToSerialPort(String^ portName, int baudRate);
void disconnectFromSerialPort();
void setCurrentPosition(int channel, int position);
int getCurrentPosition(int channel);
void moveToPosition(int channel, int position);
private:
void initConnection();
SerialPort^ serialPort;
array<String^> ^serialPortNames;
String^ portName;
int baudRate;
vector<int> currentPosition;
};
一切正常,直到我将最后一行更改int currentPosition
为vector<int> currentPosition
. 如果我现在尝试编译/调试,我会收到以下错误消息:
error C2143: syntax error : missing ';' before '<'
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
error C2238: unexpected token(s) preceding ';'
我检查了 MSDN 以获取有关这些错误代码的更多信息,但我无法弄清楚代码有什么问题。有任何想法吗?