Skip to content
#include<iostream.h>
#include<conio.h>
class student
{
int rollno;
char name[50];
public:
student()
{
cout<<"Enter the Rollno : ";
cin>>rollno;
cout<<"Enter the Name : ";
cin>>name;
}
virtual void show()
{
cout<<"\tStudent Record\n Rollno : "<<rollno<<"\n Name : "<<name;
}
};
class test : public student
{ float total;
float sub[5];
public:
test();
void show();
};
test::test()
{
total=0;
cout<<"\tEnter Marks\n";
for(int i=0;i<5;i++)
{
cout<<"Subject "<<i<<": ";
cin>>sub[i];
total+=sub[i];
}
}
void test::show()
{
cout<<"\nMarks";
for(int i=0;i<5;i++)
cout<<"\nSubject "<<i<<": "<<sub[i];
cout<<"\n Total : "<<total;
}
int main()
{
clrscr();
test obj;
obj.student::show();
obj.show();
getch();
return 0;
}
Class diagram
Related Posts:
C++ Program to draw a bird with nest (Simple graphics)
#include <iostream.h>
#include <conio.h>
#include <graphics.h>
void main()
{
int gd=DETECT,gm;
initgraph(&gd,&gm,"C:\\Tc\… Read More
C++ program to implement shearing in graphics
A shear is a transformation that distorts the shape of an object along either or both of the axies. Like scale and translate, a shear can be done alo… Read More
C++ Program to implement scaling in graphics
A scaling can be represented by a scaling matrix. To scale an object by a vector v = (vx, vy, vz), each point p = (px, py, … Read More
C++ Program to draw umbralla couple (Simple Graphics)
#include <iostream.h>
#include <conio.h>
#include <graphics.h>
void main()
{
int gd=DETECT,gm;
initgraph(&gd,&gm,"… Read More
C++ Program to draw a cockroach (Simple Graphics)
#include <iostream.h>
#include <conio.h>
#include <graphics.h>
void main()
{
int gd=DETECT,gm;
initgraph(&gd,&gm,"C:\\Tc\… Read More
0 comments:
Post a Comment