Practical : 12
Subject : Object Oriented
Programming with C++
Aim : C++ program to demonstrate concept of constructor
Source Code :
#include<iostream.h>
#include<conio.h>
class s
{
public:
s()
{
}
s(intx,int y)
{
int z;
z=x+y;
cout<<"x : "<<x<<endl<<"y : "<<y<<endl;
cout<<"x + y = "<<z;
}
};
void main()
{
clrscr();
s(10,12);
getch();
}
Output :
0 comments:
Post a Comment