This is the header of a class I am working on in 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;
};
Everything worked fine until I changed the last line int currentPosition to vector<int> currentPosition. If I try to compile / debug now, I get these error messages:
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 ';'
I checked MSDN for some more info on these error codes, but I cannot figure out what is wrong with the code. Any ideas?
vector is template defined within std namespace, thus you should write std::vector<int> instead of vector<int>.
Alternatively you could write using namespace std; at the beginning of this file, but note that this is considered bad practice since it could cause some of names of your classes to become ambiguous.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With