C 實現學生類,C 實現一個學生類

時間 2021-08-30 11:04:04

1樓:靜心先生

#include

#include

using namespace std;

class student

void display()

private:

string name;

string id;

int grade;

int banji;

int nianji;

};int main()

2樓:

oid scortbychinese(void);//對學生的語文成績排序

void scortbymath(void); //對學生的數學成績排序

void scortbyenglish(void);//對學生的英語成績排序

void scortbytotal(void);//對學生的總分排序

3樓:程式設計大亨

#define _crt_secure_no_warnings#include

#include

using namespace std;

//建立學生類

class student

//建構函式

void insertinfo()

void printinfo()

{cout << "姓名:" << name << "\t" << "學號:" << num <<"\t"<< "總成績:"<

執行截圖:

多個學生資訊,使用結構體陣列或者結構體指標動態申請,加上while迴圈

4樓:匿名使用者

c++類的定義

c++中使用關鍵字 class 來定義類, 其基本形式如下:

class 類名

;示例:

定義一個點(point)類, 具有以下屬性和方法:

■ 屬性: x座標, y座標

■ 方法: 1.設定x,y的座標值; 2.輸出座標的資訊。

實現**:

class point

; 學生類可以這樣寫:

class student;}

5樓:丶草昧醬

class student

6樓:匿名使用者

學生類student中有3 個私有資料成員:i_xuehao(學號)、s_xingming(姓名)、i_nianling(年齡);3 個公有成員函式:student(建構函式)、display、~student(解構函式)。

使用建構函式為student 類的物件賦值(s_xingming 使用動態記憶體分配空間),display顯示學生所有資訊。

#include

#include

using namespace std;

class student

;student::student(string n,int i,int a)

void student::display()student::~student(){}void main()

使用c++編寫一個學生類 10

7樓:匿名使用者

這麼基礎的,樓主自己寫啊,多看看課本就可以寫出來了。

用c++寫一個學生類,類名student,

8樓:

#include

#include

using namespace std;

class student

student(string n, string c, int a)printinfo()

};int main()

如何用c++定義一個學生類?

9樓:

#include "iostream.h"

#include "string.h"

class student

;void p()

};void main()

用c++編寫一個學生類。輸出每個學生的姓名、學號、成績

10樓:靜心先生

#include

#include

using namespace std;

class student

void display();

private:

string name;

int id;

int score;

};void student::display()int main()

建立一個學生類student,用c++程式設計實現

11樓:匿名使用者

**如下:

#include

#include

using namespace std;

class student

student(int id, const char * name)

student(int id, const char * name, int age, const char *major)

~student()

if (this->major)

}int getid() const

void setid(int id)

const char * getname() const

void setname(const char * name)

int len = strnlen_s(name, 20);

this->name = new char[len + 1];

strcpy_s(this->name, len + 1, name);

}int getage() const

void setage(int age)

const char * getmajor() const

void setmajor(const char * major)

int len = strnlen_s(major, 20);

this->major = new char[len + 1];

strcpy_s(this->major, len + 1, major);

}private:

int id;

char * name;

int age;

char * major;

};void printstudent(const student& student)

int _tmain(int argc, _tchar* argv)

c 實現學生成績管理系統

include include include include class student 建構函式,用來建立物件同時初始化相關指標變數。student student 從檔案中獲取學生的資訊。int student get info while out 迴圈讀檔案,直到讀到了檔案的末尾。elsel...

c中怎麼定義類,c 中怎麼定義一個類

using system public class desk 基類desk 設定desk的資訊 public void setinfo int len,int wid,int hei 列印desk的引數資訊 public void showinfo t width t height length,w...

c 如何實現迴圈輸入,c 中如何進行在類裡面的迴圈多次輸入。

ctrl c是直接強行中斷程式並結束,所以沒有辦法判斷 使用 while cin x 想結束迴圈就輸入 回車,ctrl z 手機使用者 你申明的都是double 型別 但是你scanf 卻是 f 最後面還有一個return 0 按理說 在main主函式裡面 一個scanf就會輸入一次 你肯定沒有輸入...