165. Write a program to overload the constructor?

#include<iostream.h> #include<conio.h> class demo {                 int a,b; public:                 demo()                                 {                                 a=10;                                 b=20;                                 display();                                 }                 demo(int x)                                 {                                 a=x;                                 b=30;                                 display();                                 }                 demo(int y,int z)                                 {                                 a=y;                                 b=z;                                 display();                                 } private:                 void display()                                 {                                ... Continue Reading →

Advertisements

164. Write a program to initialize the member variable in different ways using constructor?

#include<iostream.h> #include<conio.h> class demo {                 int a,b; public:                 demo(int y,int z)                                 {                                 a=y;                                 b=z;                                 display();                                 } private:                 void display()                                 {                                 cout<<"A = "<<a<<endl;                                 cout<<"B = "<<b<<endl;                                 } }; void main() {                 clrscr();                 demo d(10,20);                 getch(); }

Create a website or blog at WordPress.com

Up ↑

%d bloggers like this: