我在#"之前得到了一个"预期的主要表达式。并花了一些时间试图找到问题,但似乎无法找到它......我将它缩小到.h文件和构造函数。这是代码。任何帮助,将不胜感激。
#ifndef VEHICLE_H
#define VEHICLE_H
#include <iostream>
using namespace std;
class Vehicle{
protected:
char *name;
static ostream *out;
public:
Vehicle();
Vehicle(string n);
Vehicle (const Vehicle & b);
~Vehicle();
Vehicle& operater =(const Vehicle &b);
virtual void print() = 0;
virtual void read() = 0;
};
#endif // VEHICLE_H
~
单独文件中的构造函数。
#include "vehicle.h"
Vehicle :: Vehicle(){
name = "";
}
Vehicle :: Vehicle(string n){
name = n.c_str();
}
Vehicle :: Vehicle(const Vehicle & a){
int len = strlen(a.name)+ 1;
name = new char[len];
strcpy(name,a.name);
}
Vehicle :: Vehicle &operater = (const Vehicle &b){
if(this = &b){
return *this;
}
int len = strlen(a.name)+ 1;
name = new char[len];
strcpy(name,a.name);
return *this;
}
Vehicle:: ~Vehicle(){
delete [] name;
}
再次感谢。
答案 0 :(得分:0)
在您的课程车辆中,您拼错了操作员:
/.+Back\s([^\s\.]+).+/
编辑:你每次都拼错了。