函數調用缺少參數列表是什么意思
#include<stdlib.h>
#include<iostream>
#include<string>
using namespace std;
class Student
{
public:
void setName(string _name)//參數的命名,這里使用下劃線
{
m_strName = _name;
}
string getName()
{
return m_strName;
}?
void setGender(string _gender)//參數的命名,這里使用下劃線
{
m_strGender = _gender;
}
string getGender()
{
return m_strGender;
}
int getScore()//int 返回值
{
return m_iScore;
}
void initScore()//通過初始化來定義初值
{
m_iScore = 0;
}
void study(int _score)
{
m_iScore += _score;//m_Score=m_iScore+_score
}
private:
string m_strName;
? ? string m_strGender;
int m_iScore;
};
int main(void)
{
Student stu;
stu.initScore();
stu.setName("zhangsan");
stu.setGender("女");
stu.study(5);
stu.study(3);
cout << stu.getName << " " << stu.getGender << " " << stu.getScore << endl;
system("pause");
return 0;
}
錯誤 2 error C3867: “Student::getName”: ?函數調用缺少參數列表;請使用“&Student::getName”創建指向成員的指針 e:\vstext\text\text\text.cpp 54 1 text
2016-04-30
main函數里的cout后面,每一個函數調用的時候沒有加(),修改如下
cout<<sut.getName()<<" "<<stu.getGender()<<" "<<stu.getScore()<<endl;
2016-08-16
我也用推薦的IDE寫這個程序,和你的錯誤一樣,被坑了好久