我是新手复制构造函数,当我开始使用向量时似乎无法让它们工作.
// ROBOT CLASS
class Robot {
private:
char *name;
int size;
int cmdCount;
command *cmdList;
char items[8][16];
int resources[3]; // silver, gold, then platinum
public:
Robot( );
Robot(int num_of_cmds, const char *nm);
Robot(const Robot &);
~Robot( );
const char *get_name( );
command get_command(int pos) const;
void set_item(const char item[ ], int pos);
const char *get_item(int pos);
};
// ROBOT CONSTRUCTOR default
Robot::Robot( ) {
// Load Robot name
cmdCount = 5;
try {
name = new char[11];
}
catch(std::bad_alloc) …Run Code Online (Sandbox Code Playgroud)