啊哈磊_编程从这里起步

标题: c++为什么运行不了? [打印本页]

作者: zcy961024    时间: 2015-5-3 10:35
标题: c++为什么运行不了?
# include "iostream"
# include "string"
using namespace std;
class Student
{
public:
        int age;
        char *name;
        public:
        Student()
        {
               
        }
        Student(int m,char *n)
        {
                age=m;
                name=new char[strlen(n)+1];
                strcpy(name,n);
        }
        void SetName(int m,char *n)
        {
            age=m;
                name=new char[strlen(n)+1];
                strcpy(name,n);
        }
        int Getage()
        {
                return age;
        }
        char *Getname()
        {
                return name;
        }
};
int main()
{
        Student *student;
        student=new Student[3];
        cout<<"请输入第一名学生的年龄和名字";
        cin>>student[0].age>>student[0].name;
        cout<<"请输入第二名学生的年龄和名字";
        cin>>student[1].age>>student[1].name;
        cout<<"请输入第三名学生的年龄和名字";
        cin>>student[2].age>>student[2].name;
        cout<<"姓名:"<<student[0].Getname()<<" "<<"年龄:"<<student[0].Getage()<<endl;
        cout<<"姓名:"<<student[1].Getname()<<" "<<"年龄:"<<student[1].Getage()<<endl;
        cout<<"姓名:"<<student[2].Getname()<<" "<<"年龄:"<<student[2].Getage()<<endl;
}


作者: 鹿鹿杏仁鹿    时间: 2015-5-7 22:01
你是说用啊哈C编译C++!?这是没有的事。。
作者: 狗狗Hello    时间: 2015-5-11 20:08
因为C++不是C
作者: 狗狗Hello    时间: 2015-5-19 11:28
这是C语言,不是C++




欢迎光临 啊哈磊_编程从这里起步 (https://bbs.codeaha.com/) Powered by Discuz! X3.2