0% found this document useful (0 votes)
16 views7 pages

Task#1

The document defines three C++ classes - Record, CRecord, and CResult that represent student records. Record stores basic student data. CRecord inherits from Record and stores additional course marks. CResult inherits from CRecord and calculates the total marks. It also overrides the display method to output the student details. The main function creates a CResult object and calls its display method.

Uploaded by

Abu Sufyan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views7 pages

Task#1

The document defines three C++ classes - Record, CRecord, and CResult that represent student records. Record stores basic student data. CRecord inherits from Record and stores additional course marks. CResult inherits from CRecord and calculates the total marks. It also overrides the display method to output the student details. The main function creates a CResult object and calls its display method.

Uploaded by

Abu Sufyan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Task#1

#include<iostream>

using namespace std;

class record

string rollno,c1,c2;

public:

record(string r,string c,string a)

rollno=r;

c1=c;

c2=a;

string getroll()

return rollno;

string getc1()

return c1;

string getc2()

return c2;

virtual void display()

{
}

};

class Crecord:public record

int mc1,mc2;

public:

Crecord(int m1,int m2,string r,string c,string a):record(r,c,a)

mc1=m1;

mc2=m2;

int getm1()

return mc1;

int getm2()

return mc2;

};

class Cresult:public Crecord

int tmarks;

public:

Cresult(int j,int k,string l,string m,string n):Crecord(j,k,l,m,n)

}
int gettmarks()

tmarks=getm1()+getm2();

return tmarks;

void display()

cout<<"Roll_no="<<getroll()<<endl;

cout<<"course_1="<<getc1()<<endl;

cout<<"course_2="<<getc2()<<endl;

cout<<"marksC1="<<getm1()<<endl;

cout<<"marksC2="<<getm2()<<endl;

cout<<"total marks="<<gettmarks()<<endl;

};

int main()

record *obj;

Cresult r(80,85,"338","calculas","pf");

obj=&r;

obj->display();

system("pause");

return 0;
}

Task#2
person
-
Name

age

Person()

Void display()

professor staff

course ID -staff ID

coursename department

professor() staff()

display() showdata ()

Researcher

Lab ID

experimentNo

Researcher()

Getdata()
Task#3
#include<iostream>

using namespace std;

class person

protected:

string name;

int age;

public:

person(string n,int a)

name=n;

age=a;

};

class staff:public person

string staffID,department;

public:

staff(string id,string d,string n,int a):person(n,a)

staffID=id;

department=d;

void showdata()

cout<<"name="<<name<<endl;

cout<<"age="<<age<<endl;
cout<<"staffID="<<staffID<<endl;

cout<<"department="<<department<<endl;

};

class professor:public person

string cID,Cname;

public:

professor(string c,string cn,string n,int a):person(n,a)

cID=c;

Cname=cn;

void dispaly()

cout<<"course ID="<<cID<<endl;

cout<<"Course name="<<Cname<<endl;

};

class Researcher:public staff,public professor

int labID,experimentNo;

public:

Researcher(int l,int e,string c,string cn,string id,string d,string n,int


a):staff(id,d,n,a),professor(c,cn,n,a)

labID=l;

experimentNo=e;

}
void getdata()

cout<<"labID="<<labID<<endl;

cout<<"experimentNo="<<experimentNo<<endl;

};

int main()

Researcher obj(345,5,"416","oop","6789","bscs","sufyan",21);

obj.showdata();

obj.dispaly();

obj.getdata();

system("pause");

return 0;

You might also like