* Lets start learning CPP (C++) Using Example.
* Simple class creation using C++
//Written by Latest Technology Guide
//Title : OOCP (CPP) : Example # 06 : Multiple Class Declaration using C++
#include <iostream.h>
#include <iomanip.h>
#include <conio.h>
class A
{
private:
int i;
float j;
public:
A()
{
cout << "A Constructor is called" << endl;
i = 1000;
j = 2.134;
}
void display()
{
cout << "i = " << i << setw(10) << "j = " << j << endl;
}
};
class B
{
private:
int c;
char ch;
double f;
public:
void display()
{
cout << "c = " << c << setw(10) << "ch = " << ch
<< setw(10) << "f = " << f
<< endl;
}
};
void main()
{
clrscr();
A obj1;
B obj2;
obj1.display();
obj2.display();
getch();
}
Output:
* Simple value as you have set into class will display.
--------------------------------------------------------------------------------
OOCP (CPP) : Example # 06 : Multiple Class Declaration using C++.
* Example shows how to create multiple class in c++.
Note: All programs are developed and tested using Turbo C++ 3.0 under Windows XP. We just want to provide guidelines to the users. If you are using any other Compiler or other operating system they you need to modify this program as per your requirements.
No comments:
Post a Comment