Write a program to use default constructor


 

/* Write a program to use default constructor*/

#include<iostream.h>

#include<conio.h>

class sum

{

public:

sum(int x)

{

cout<<“x=”<<x;

}};

void main()

{

clrscr();

sum s1(10);

getch();

}

 

/*output:   x=10*/

 

Related Posts

Comments are closed.