第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定

如果是多個.c 和.h文件編程是不是要把這些文件都放到一個文件夾中呢,我的代碼總是提示 undefined reference to `Student::Student()'


//這是Student.cpp文件

#include"Student.h"

#include<iostream>

using namespace std;


Student::Student()

{

? ?cout<<"hello mook"<<endl;

}


void Student::setAge(int _age)

{

? ?age = _age;


}

int Student::getAge()

{

? ?return age;

}



//下面是Student.h 文件


class Student

{


public:

? ?Student();

? ?void setAge(int _age);

? ?int getAge();

private:

? ?int age;

};

//下面是main.cpp 文件

#include <iostream>

#include"Student.h"

using namespace std;


int main()

{

? ?Student *p = new Student();

? ?p->setAge(100);

? ?cout<<p->getAge()<<endl;

? ?delete p;

? ?p = NULL;

? ?return 0;

}


正在回答

舉報

0/150
提交
取消
C++遠征之封裝篇(下)
  • 參與學習       70903    人
  • 解答問題       531    個

封裝--面向?qū)ο笕筇卣髦?,通過案例讓C++所學知識融會貫通

進入課程

如果是多個.c 和.h文件編程是不是要把這些文件都放到一個文件夾中呢,我的代碼總是提示 undefined reference to `Student::Student()'

我要回答 關注問題
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號