一个c++作业,用无参数的构造函数和数组完成,不明白为什么出错
吴亚萌 2016-12-21 11:08:10 //定义一个Student类,属性为:姓名name,年龄age,街道地址street,城市city,邮编zip,
//包括设置和提取姓名,年龄,街道地址,城市和邮编等操作
//包括display()方法,要求输出如下表所示信息。
//声明一个有四个student类的数组,运用默认形参值得构造函数
#include<iostream>
using namespace std;
//定义Student类
class Student{
public:
Student(){
name=0;
age=0;
street=马岗大道3号;
city=顺德;
zip=528305;
}
// static void f(){
//cout<<"马岗大道3号";}
// static void g(){
//cout<<"顺德";}
// static void h(){
//cout<<"528305";}
void studentName();
void studentAge();
void display(){
cout<<studentName<<studentAge <<street<<city<<zip ;}
~Student();
//cout<<studentAge ;
//Student::f();
// Student::g();
// Student::h();}
private:
string name,age;street,city,zip;
// static string street,city,zip;
};
void Student::studentName(string namee){
string getName(){
return name;}
};}
void Student::studentAge(string agee){
string getAge(){
return age;}
};}
int main(){
Student stu[4];
for(int i=0;i<4;i++)
cout<<"请输入学生姓名 ";
cin>>stu[i].studentName();
cout<<"请输入该学生年龄 ";
cin>>stu[i].studentAge;
stu[i].display();
return 0;
}