您的位置:首页 > 编程语言 > C语言/C++

函数调用缺少参数列表;请使用“&Student::Printf”创建指向成员的指针 问题解析

2017-03-11 12:02 645 查看
大家经常犯的一个错误   函数调用缺少参数列表;请使用“&Student::Printf”创建指向成员的指针

例如代码:

#include<iostream>
using namespace std;

struct Student
{
char _name[20];
char _sex[6];
int _age;

void InitStudent(char* pname, char* psex, int age)
{
strcpy_s(_name, pname);
strcpy_s(_sex, psex);
_age = age;

}

void Printf()
{
cout << _name << " " << _sex << " " << _age << endl;
}

};

int main()
{
Student std1;
std1.InitStudent("dandna", "women", 20);
std1.Printf;
system("pause");
return 0;
}

编译后提示:


这是因为在调用Printf时忘记加括号。正确的是std.Printf()
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  常见错误 C++
相关文章推荐