这个程序为什么不对?

[复制链接]
查看11 | 回复2 | 2011-6-22 21:01:58 | 显示全部楼层 |阅读模式
#include
#include
using namespace std;
class stud
{
public:
        stud(string se,string we,int a):sex(se),name(we),num(a){}
        void display();
private:
        string sex;
        string name;
        int num;
};
void stud::display()
{
        coutf:\程序\实验\23\23\23.cpp(26) : error C2065: 'gh' : undeclared identifier
1>f:\程序\实验\23\23\23.cpp(26) : error C2065: 'lkl' : undeclared identifier到底怎么回事?

回复

使用道具 举报

千问 | 2011-6-22 21:01:58 | 显示全部楼层
int main(){stud stud1(“gh”,"lkl",1); //这里要加双引号,才表示字符串stud1.display();getchar();return 0;}因为如果不加双引号,则表示gh和lkl是标识符,而在主函数中并没有申明这两个变量,所以会出错。记得表示字符串的值时要加双引号。楼主给分吧。。!!~~...
回复

使用道具 举报

千问 | 2011-6-22 21:01:58 | 显示全部楼层
你的实参gh,lkl没有定义和赋值...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行