C++lombok 编译报错时一直报错 求看看问题

大家看看这个编译错误是怎么回事?
[问题点数:20分]
大家看看这个编译错误是怎么回事?
[问题点数:20分]
不显示删除回复
显示所有回复
显示星级回复
显示得分回复
只显示楼主
2013年2月 移动平台大版内专家分月排行榜第三
本帖子已过去太久远了,不再提供回复功能。C++编程题编译时提示错误,但我没发现哪里错了,求帮忙看看_百度知道
C++编程题编译时提示错误,但我没发现哪里错了,求帮忙看看
int&max&#include&&int&Array_using&main(){&nbsp:&i.&}void&i++)&max=array[0];}void&i& cin&max=&int&&cout&lt.hiphotos.jpg" esrc="&nbsp.max_value();&for(i=0;&//定义array_max的成员函数max_value(). &int&&0;void&nbsp.h&i++)&nbsp:set_value()&show_value();max)&Array_return&nbsp://d;}<img class="ikqb_img" src="http.array[10];&&/zhidao/wh%3D450%2C600/sign=63cd19f0c2fdfc03e52debbce10faba2/bde6cb4;class& //定义类array_max的成员函数set_value()://d,实现输入10个数据{&&};//定义类Array_max{public.&i;/zhidao/pic/item/bde6cb4;i&&//定义array_max的成员函数show_value():&nbsp,实现数组中最大值的输出{&& if(array[i]&&void&nbsp.set_value().com/zhidao/wh%3D600%2C800/sign=bcaf3feefc5/bde6cb4;&&Array_max&void&max_value();10;10;namespace&}int&nbsp,实现求数组中的最大值{&array[10];set_value():;show_value()&arrmax:max_value()&nbsp:.arrmax.show_value();string//找出一个整形数组中的元素最大值#include&Array_&iostream&for(i=1://d
提问者采纳
show_value(); void show_value():show_value() &#47: void set_value();&i++)
cin&};void Array_#include &去掉分号{&& arrmax.set_value();i&max) max=array[i];max&lt:;max=&10;iostream&class Array_max
if(array[i]&gt修改如下:;/ void max_value(); for(i=0;加上类名哦{ cout&&gt:见注释#include & for(i=1;&&lt.h&10改成i}void Array_i&// max=array[0]: int array[10]:max_value() {10:set_value()
{}int main(){ Array_&#47.max_value();}void Array_array[i]; arrmax:; return 0
提问者评价
按照你说的,真的成功了,好开心,谢谢你!
来自团队:
其他类似问题
为您推荐:
其他3条回答
i&array[i];i++)
cin&ERR1;ERR2;&#47class Array_max /定义类array_max的成员函数set_value();ERR3,实现输入10个数据{ for(i=0:类中的函数在类外定义要加上类属{}void Array_/
&#47::这里多分号{}void Array_/&10:show_value() &#47:set_value()
&#47:;&#47
class Array_
//定义类Array_max后面的分号是多余的吧!!!
class Array_
//定义类Array_max这一行,不要分号吧。
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁当前访客身份:游客 [
当前位置:
设计一个学校在册人员类(Person)。数据成员包括:身份证号(IdPerson),姓名(Name),性别(Sex),生日(Birthday)和家庭住址(HomeAddress)。成员函数包括人员信息的录入和显示。还包括构造函数与拷贝构造函数。设计一个合适的初始值
#include &iostream&
#include &string&
class Person{
string IdP
string HomeA
~Person(){}//析构函数 &注意:一个类中只有一个析构函数,用于结束对象
Person(string,string,string,string,string,string);&
Person(Person&);
string GetIdPerson();
string GetName();
string GetSex();
string GetBirthday();
string GetHomeAddress();
IdPerson='0'; Name='0'; Sex='0';
Birthday='0'; HomeAddress='0';
}//构造函数默认值
Person(Person p1){
IdPerson=p.IdP Name=p.N Sex=p.S
Birthday=p.B HomeAdress=p.HomeA
}//复制构造函数
Person(string id,string name,string sex,string bir,string hd){
IdPerson= Name= Sex=
Birthday= HomeAdress=
}//带参构造函数初始化
Person(Person & p2){
IdPerson=p.IdP Name=p.N Sex=p.S
Birthday=p.B HomeAdress=p.HomeA
}//复制构造函数
string Person::GetName(){
string Person::GetIdPerson(){
return IdP
string Person::GetSex(){
string Person::GetBirthday(){
string Person::GetHomeAddress(){
return HomeA
void main(){
string a,b,c,d,e;
cout&&"默认构造函数下的、"&&
Person p1;
cout&&"身份证号码:"&&p1.GetIdPerson()&&"\n"&&"姓名:"&&p1.GetName()&&"\n"
&&"性别:"&&p1.GetSex()&&"\n"&&"生日:"&&p1.GetBirthday()&&"\n"
&&"家庭住址:"&&p1.GetHomeAddress()&&
cout&&"请输入身份证号码:"&&
cout&&"请输入姓名:"&&
cout&&"请输入性别:"&&
cout&&"请输入生日:"&&
cout&&"请输入家庭地址:"&&
Person p2(a,b,c,d,e);
cout&&"身份证号码:"&&p1.GetIdPerson()&&"\n"&&"姓名:"&&p1.GetName()&&"\n"
&&"性别:"&&p1.GetSex()&&"\n"&&"生日:"&&p1.GetBirthday()&&"\n"
&&"家庭住址:"&&p1.GetHomeAddress()&&
错误提示:
:\应用软件\C++\Microsoft Visual Studio\MyProjects\C_study\3\3.cpp(25) : error C2065: 'IdPerson' : undeclared identifier
C:\应用软件\C++\Microsoft Visual Studio\MyProjects\C_study\3\3.cpp(25) : error C2065: 'Name' : undeclared identifier
C:\应用软件\C++\Microsoft Visual Studio\MyProjects\C_study\3\3.cpp(25) : error C2065: 'Sex' : undeclared identifier
C:\应用软件\C++\Microsoft Visual Studio\MyProjects\C_study\3\3.cpp(26) : error C2065: 'Birthday' : undeclared identifier
C:\应用软件\C++\Microsoft Visual Studio\MyProjects\C_study\3\3.cpp(26) : error C2065: 'HomeAddress' : undeclared identifier
C:\应用软件\C++\Microsoft Visual Studio\MyProjects\C_study\3\3.cpp(27) : warning C4508: 'Person' : function s 'void' return type assumed
C:\应用软件\C++\Microsoft Visual Studio\MyProjects\C_study\3\3.cpp(29) : error C2146: syntax error : missing ')' before identifier 'p1'
C:\应用软件\C++\Microsoft Visual Studio\MyProjects\C_study\3\3.cpp(29) : error C2501: 'Person' : missing storage-class or type specifiers
C:\应用软件\C++\Microsoft Visual Studio\MyProjects\C_study\3\3.cpp(29) : error C2373: 'Person' : different type modifiers
& & & & C:\应用软件\C++\Microsoft Visual Studio\MyProjects\C_study\3\3.cpp(24) : see declaration of 'Person'
C:\应用软件\C++\Microsoft Visual Studio\MyProjects\C_study\3\3.cpp(29) : error C2440: 'initializing' : cannot convert from 'int (__cdecl *)(void)' to 'int'
& & & & This conversion requires a reinterpret_cast, a C-style cast or function-style cast
C:\应用软件\C++\Microsoft Visual Studio\MyProjects\C_study\3\3.cpp(29) : error C2059: syntax error : ')'
C:\应用软件\C++\Microsoft Visual Studio\MyProjects\C_study\3\3.cpp(29) : error C2143: syntax error : missing ';' before '{'
C:\应用软件\C++\Microsoft Visual Studio\MyProjects\C_study\3\3.cpp(29) : error C2447: missing function header (old-style formal list?)
C:\应用软件\C++\Microsoft Visual Studio\MyProjects\C_study\3\3.cpp(35) : error C2679: binary '=' : no operator defined which takes a right-hand operand of type 'class std::basic_string&char,struct std::char_traits&char&,class std::allocator&char& &'
&(or there is no acceptable conversion)
C:\应用软件\C++\Microsoft Visual Studio\MyProjects\C_study\3\3.cpp(35) : error C2679: binary '=' : no operator defined which takes a right-hand operand of type 'class std::basic_string&char,struct std::char_traits&char&,class std::allocator&char& &'
&(or there is no acceptable conversion)
C:\应用软件\C++\Microsoft Visual Studio\MyProjects\C_study\3\3.cpp(35) : error C2679: binary '=' : no operator defined which takes a right-hand operand of type 'class std::basic_string&char,struct std::char_traits&char&,class std::allocator&char& &'
&(or there is no acceptable conversion)
C:\应用软件\C++\Microsoft Visual Studio\MyProjects\C_study\3\3.cpp(36) : error C2679: binary '=' : no operator defined which takes a right-hand operand of type 'class std::basic_string&char,struct std::char_traits&char&,class std::allocator&char& &'
&(or there is no acceptable conversion)
C:\应用软件\C++\Microsoft Visual Studio\MyProjects\C_study\3\3.cpp(36) : error C2065: 'HomeAdress' : undeclared identifier
C:\应用软件\C++\Microsoft Visual Studio\MyProjects\C_study\3\3.cpp(36) : error C2679: binary '=' : no operator defined which takes a right-hand operand of type 'class std::basic_string&char,struct std::char_traits&char&,class std::allocator&char& &'
&(or there is no acceptable conversion)
C:\应用软件\C++\Microsoft Visual Studio\MyProjects\C_study\3\3.cpp(37) : warning C4508: 'Person' : function s 'void' return type assumed
C:\应用软件\C++\Microsoft Visual Studio\MyProjects\C_study\3\3.cpp(39) : error C2065: 'p2' : undeclared identifier
C:\应用软件\C++\Microsoft Visual Studio\MyProjects\C_study\3\3.cpp(39) : error C2563: mismatch in formal parameter list
C:\应用软件\C++\Microsoft Visual Studio\MyProjects\C_study\3\3.cpp(39) : error C2448: '&Unknown&' : function-style initializer appears to be a function definition
C:\应用软件\C++\Microsoft Visual Studio\MyProjects\C_study\3\3.cpp(63) : error C2146: syntax error : missing ';' before identifier 'p1'
C:\应用软件\C++\Microsoft Visual Studio\MyProjects\C_study\3\3.cpp(63) : warning C4551: function call missing argument list
C:\应用软件\C++\Microsoft Visual Studio\MyProjects\C_study\3\3.cpp(63) : error C2065: 'p1' : undeclared identifier
C:\应用软件\C++\Microsoft Visual Studio\MyProjects\C_study\3\3.cpp(64) : error C2228: left of '.GetIdPerson' must have class/struct/union type
C:\应用软件\C++\Microsoft Visual Studio\MyProjects\C_study\3\3.cpp(64) : error C2228: left of '.GetName' must have class/struct/union type
C:\应用软件\C++\Microsoft Visual Studio\MyProjects\C_study\3\3.cpp(65) : error C2228: left of '.GetSex' must have class/struct/union type
C:\应用软件\C++\Microsoft Visual Studio\MyProjects\C_study\3\3.cpp(65) : error C2228: left of '.GetBirthday' must have class/struct/union type
C:\应用软件\C++\Microsoft Visual Studio\MyProjects\C_study\3\3.cpp(66) : error C2228: left of '.GetHomeAddress' must have class/struct/union type
C:\应用软件\C++\Microsoft Visual Studio\MyProjects\C_study\3\3.cpp(77) : error C2146: syntax error : missing ';' before identifier 'p2'
C:\应用软件\C++\Microsoft Visual Studio\MyProjects\C_study\3\3.cpp(77) : warning C4551: function call missing argument list
C:\应用软件\C++\Microsoft Visual Studio\MyProjects\C_study\3\3.cpp(78) : error C2228: left of '.GetIdPerson' must have class/struct/union type
C:\应用软件\C++\Microsoft Visual Studio\MyProjects\C_study\3\3.cpp(78) : error C2228: left of '.GetName' must have class/struct/union type
C:\应用软件\C++\Microsoft Visual Studio\MyProjects\C_study\3\3.cpp(79) : error C2228: left of '.GetSex' must have class/struct/union type
C:\应用软件\C++\Microsoft Visual Studio\MyProjects\C_study\3\3.cpp(79) : error C2228: left of '.GetBirthday' must have class/struct/union type
C:\应用软件\C++\Microsoft Visual Studio\MyProjects\C_study\3\3.cpp(80) : error C2228: left of '.GetHomeAddress' must have class/struct/union type
执行 cl.exe 时出错.
3.obj - 1 error(s), 0 warning(s)
共有3个答案
<span class="a_vote_num" id="a_vote_num_
1. HomeAddress有几处拼写错了
2. 类外定义函数时,使用“类名::函数名”的形式(几个构造函数就是因为这个原因编译错误)
3. 删除Person(Person p1)函数
4. Person(string id,string name,string sex,string bir,string hd)的声明是错误的,声明多了一个参数
5. 打印输出的是中文,要使用GBK来保存源文件
--- 共有 2 条评论 ---
: 你仔细数一下你的声明(Person(string,string,string,string,string,string); )和你定义(Person(string id,string name,string sex,string bir,string hd))的参数个数嘛,写程序还是要细心一点,这些错误其实都不是很难,看看错误提示找一找源程序或者在网上查一查
(6个月前)&nbsp&
为什么那样就多声明了一个参数 不太懂 能不能解释一下 谢谢
(6个月前)&nbsp&
<span class="a_vote_num" id="a_vote_num_
大哥,定义类的成员方法不在class里面请加类名class::function
比如person::getpersonid
<span class="a_vote_num" id="a_vote_num_
好好看看书吧。
第一,看下类外定义类成员函数的方式(主要问题所在),后面的都能写对,前面咋就写不对呢
第二,Person(Person p1)这条你声明了吗??
--- 共有 3 条评论 ---
: 谢谢 我懂了
周六日这两天忙其他事情了 没来得及看 谢谢
(6个月前)&nbsp&
: 不合法就不要用嘛
(6个月前)&nbsp&
Person(Person p1)这样声明是不合法的,会导致循环调用复制构造函数
(6个月前)&nbsp&
更多开发者职位上
有什么技术问题吗?
电一样的...的其它问题
类似的话题

我要回帖

更多关于 eclipse不报编译错误 的文章

 

随机推荐