/*
Dynamic Constructor Demonstrate
*/
#include<iostream>
using namespace std;
class Sample
{
int a,b;
public:
Sample(int x,int y)
{
a=x;
b=y;
}
void display()
{
cout<<"\n\n A:"<<a;
cout<<"\n B: "<<b;
}
};
int main()
{
int a,b;
cout<<"\n\n Enter any two number for object s1: ";
cin>>a>>b;
Sample S1(a,b); // Implicit Call
cout<<"\n\n Enter any two number for object s2: ";
cin>>a>>b;
Sample S2= Sample(a,b); // Implicit Call
cout<<"\n\n Object S1: ";
S1.display();
cout<<"\n\n Object S2: ";
S2.display();
return 0;
}
Dynamic Constructor Demonstrate
*/
#include<iostream>
using namespace std;
class Sample
{
int a,b;
public:
Sample(int x,int y)
{
a=x;
b=y;
}
void display()
{
cout<<"\n\n A:"<<a;
cout<<"\n B: "<<b;
}
};
int main()
{
int a,b;
cout<<"\n\n Enter any two number for object s1: ";
cin>>a>>b;
Sample S1(a,b); // Implicit Call
cout<<"\n\n Enter any two number for object s2: ";
cin>>a>>b;
Sample S2= Sample(a,b); // Implicit Call
cout<<"\n\n Object S1: ";
S1.display();
cout<<"\n\n Object S2: ";
S2.display();
return 0;
}