我有这个简单的代码,并收到语法错误:
file.cc:67: error: expected `;' before ‘{’ token
file.cc:73: error: expected primary-expression before ‘(’ token
file.cc:73: error: expected primary-expression before ‘n’
file.cc:73: error: expected `;' before ‘{’ token
Run Code Online (Sandbox Code Playgroud)
我把星星放在67和73的线条周围,它们是班级的构造者.我是C++的新手,无法找到语法问题.这是我第一次制作构造函数.
int main() {
class Patient {
private: // default is private but stating explicitly here for learning purposes
std::string name; //object
int height; //object
int weight; //object
public:
Patient(); //constructor
Patient(std::string); //constructor
void set_name (std::string n) {name=n;} //fn
void set_height (int h) {if (height>0){height=h;} else {height=0;}} //fn
void set_weight (int w) …Run Code Online (Sandbox Code Playgroud)