Sunday, December 6, 2009
Adding two numbers using single level inheritance
,
Author: Raviteja
|
Filed Under:
c++
|
#include "iostream.h"
#include "conio.h"
class one
{
private:
int c;
protected:
int a,b;
public:
void cal ();
};
class two : public one
{
public:
void accept ()
{
cout << "Welcome to add two no.s using single inheritance\n\n";
cout << "Enter 2 numbers: ";
cin >> a >> b;
}
};
void one :: cal ()
{
c = a + b;
cout << "Sum = " << c;
}
void main ()
{
clrscr ();
two T;
T.accept ();
T.cal ();
getch ();
}
Get the executable ( .exe ) file for this program..
Download
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment