0% found this document useful (0 votes)
25 views

Student

This C++ code defines classes for students including attributes like name, registration number, and marks. It defines a base student class with public, private and protected members. Then it defines two derived classes, Regular_Student and Private_Student that inherit from the base student class and add their own private attributes for school name and address respectively. The main function does not do much other than pause the program.

Uploaded by

Sallar Ali
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views

Student

This C++ code defines classes for students including attributes like name, registration number, and marks. It defines a base student class with public, private and protected members. Then it defines two derived classes, Regular_Student and Private_Student that inherit from the base student class and add their own private attributes for school name and address respectively. The main function does not do much other than pause the program.

Uploaded by

Sallar Ali
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

#include<iostream>

#include<string>
using namespace std;

class student
{
private:
string name;
protected:
string Reg_no;
public:
int marks;

void setname(string n)
{
name = n;
}
string getname()
{
return name;
}
void setReg_no(string Rn)
{
Reg_no = Rn;
}
string getReg_no()
{
return Reg_no;
}
void setmarks(int m)
{
marks = m;
}
int getmarks()
{
return marks;
}

student()
{
name = "";
Reg_no = "";
marks = 0;
}
student(string n, string Rn, int m)
{
name = n;
Reg_no = Rn;
marks = m;
}

};
class Regular_Student :public student
{
private:
string School_name;

void setSchool_name(string sn)


{
School_name = sn;
}
string getSchool_name()
{
return School_name;
}
Regular_Student()
{
string School_name;
}
Regular_Student(string sn)
{
School_name = sn;
}

};
class Private_Student :public student
{
private:
string Address;

void setAddress(string a)
{
Address = a;
}
string getAddress()
{
return Address;
}

Private_Student()
{
Address = "";
}
Private_Student(string a)
{
Address = a;
}

};

int main()
{

system("pause");
}

You might also like