| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 599 人关注过本帖
标题:请问为啥建立的对象不能用呢
取消只看楼主 加入收藏
唐兵
Rank: 2
来 自:四川泸州合江
等 级:论坛游民
帖 子:150
专家分:12
注 册:2012-12-1
结帖率:82.05%
收藏
已结贴  问题点数:10 回复次数:2 
请问为啥建立的对象不能用呢
#include <iostream>
using namespace std;
class Student
{public:
void max(Student *arr)
{float max_score=arr[0].score;
int k=0;
for(int i=1;i<5;i++)
if(arr[i].score>max_score) {max_score=arr[i].score;k=i;}
cout<<arr[k].num<<" "<<max_score<<endl;
}
Student(int n,float s):num(n),score(s){}
int num;
float score;
};
void main()
{Student o;这儿出错,错误提示信息:error C2512: 'Student' : no appropriate default constructor available
    Student stud[5]={
Student(101,78.5),Student(102,85.5),Student(103,98.5),
Student(104,10.0),Student(105,95.5)};
void max(Student* );
Student *p=&stud[0];
o.max(p);
}
搜索更多相关主题的帖子: void available default include 
2013-06-01 18:08
唐兵
Rank: 2
来 自:四川泸州合江
等 级:论坛游民
帖 子:150
专家分:12
注 册:2012-12-1
收藏
得分:0 
回复 2楼 yuccn
嗯,谢谢

一个人如果不比自己一把,你永远不知道自己究竟有多厉害
2013-06-03 16:40
唐兵
Rank: 2
来 自:四川泸州合江
等 级:论坛游民
帖 子:150
专家分:12
注 册:2012-12-1
收藏
得分:0 
回复 5楼 justlxy
哈,谢了哈

一个人如果不比自己一把,你永远不知道自己究竟有多厉害
2013-06-03 16:40
快速回复:请问为啥建立的对象不能用呢
数据加载中...
 
   



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

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