标题:一个小问题
只看楼主
忘记喧嚣
Rank: 1
等 级:新手上路
帖 子:146
专家分:0
注 册:2007-10-7
 问题点数:0 回复次数:2 
一个小问题

#include <iostream>
using std::cout;
using std::endl;

#include <string>
using std::string;

class GradeBook
{
public:
GradeBook(string name)
{
setCourseName(name);
}
void setCourseName(string name)
{
CourseName=name;
}
string getCourseName()
{
return CourseName;
}
void displayMessage()
{
cout<<"Welcome to Chongqing\n"<<getCourseName()<<"!"<<endl;
}
private:
string CourseName;
}
int main()
{
GradeBook gradebook1("世界你好! ");
GradeBook gradebook2("世界你好!");
cout<<"gradebook1 Created for course:"<<gradebook1.getCourseName()<<"\n gradebook2 Created for couse:"<<gradebook2.getCourseName()<<endl;
return 0;
}
D:\C++\Documents and Settings\GradeBook\fig03_17.cpp(6) : error C2628: 'GradeBook' followed by 'int' is illegal (did you forget a ';'?)
network.cpp
D:\C++\Documents and Settings\GradeBook\network.cpp(30) : error C2628: 'GradeBook' followed by 'int' is illegal (did you forget a ';'?)
Error executing cl.exe.

都说少个分号我不知道少在哪里啊.我写的两个程序都这样

搜索更多相关主题的帖子: return include public 
2007-10-22 12:28
忘记喧嚣
Rank: 1
等 级:新手上路
帖 子:146
专家分:0
注 册:2007-10-7
得分:0 
哦我知道了
public:
GradeBook(string name)
{
setCourseName(name);
}
void setCourseName(string name)
{
CourseName=name;
}
string getCourseName()
{
return CourseName;
}
void displayMessage()
{
cout<<"Welcome to Chongqing\n"<<getCourseName()<<"!"<<endl;
}
private:
string CourseName;
} //少分号
2007-10-22 12:33
jxnuwy04
Rank: 2
等 级:新手上路
威 望:4
帖 子:768
专家分:0
注 册:2006-9-15
得分:0 

------------------不为别的,就为你,我的理想!-----------------
2007-10-22 12:41



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-179751-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.120124 second(s), 7 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved