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

SteveSteve
Knowledge is a journey, you know? We'll get there.
Chat with Steve
FranFran
I've made my fair share of mistakes, and if I can help you avoid a few, I'd sure like to try.
Chat with Fran
DevinDevin
I've poured enough drinks to know that people don't always want advice—they just want to talk.
Chat with Devin

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