answersLogoWhite

0

// constructor program to add two number's

// program written by SuNiL kUmAr

#include<iostream.h>

#include<conio.h>

class constructor

{

private:

int a,b;

public:

constructor(int m,int n);

int sum();

};

constructor::constructor(int m,int n)

{

a=m;

b=n;

}

int constructor::sum()

{

int s;

s=a+b;

return (s);

}

int main()

{

int x,y;

clrscr();

cout<<"enter two number's to add \n";

cin>>x>>y;

class constructor k (x,y);

cout<<"sum of two number's is = "<<k.sum();

getch();

return (0);

}

User Avatar

Wiki User

14y ago

Still curious? Ask our experts.

Chat with our AI personalities

TaigaTaiga
Every great hero faces trials, and you—yes, YOU—are no exception!
Chat with Taiga
MaxineMaxine
I respect you enough to keep it real.
Chat with Maxine
ProfessorProfessor
I will give you the most educated answer.
Chat with Professor

Add your answer:

Earn +20 pts
Q: Write a program in c plus plus with constructor?
Write your answer...
Submit
Still have questions?
magnify glass
imp