answersLogoWhite

0


Best Answer

// 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
This answer is:
User Avatar

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
Related questions

Can you write own constructor in c plus plus?

Yes.


True or False A C plus plus class constructor cannot return a function value?

True - A C++ constructor cannot return a value.


How do you write a C plus plus program that will display the first 10 positive prime numbers?

By learning how to program on C+.


What is the difference between implicit and explicit call of constructor in c plus plus?

An implicit constructor call will always call the default constructor, whereas explicit constructor calls allow to chose the best constructor and passing of arguments into the constructor.


How do you write an Algorithm for a C plus plus Program?

You don't write an algorithm for a C++ program, unless you are documenting the C++ program after-the-fact. The normal procedure is to write the algorithm first, in a language independent fashion, and then translate that stated algorithm into C++ code, or into whatever language you wish.


A program c plus plus on automorphic numbers or not?

how to write a program that counts automorphic number from 1 to 999


How do you write program to convert meter to kilometer in c plus plus?

Divide it by 1000.


Do I need to write a program to find a substring in a given string in c plus plus?

No.


Write a program in c plus plus to implement macro processor?

Don't write, it is already written, google for 'cpp'.


Write a program in c plus plus to compute first of non-terminal?

there is no solution of this problem...........that's it..........


How many classes can we write in a single c plus plus program?

Its limited only by available memory.


Write a program in C programming language that computes the roots of the quadratic equation ax2 plus bx plus c?

Write your program and if you are having a problem post it here with a description of the problem you are having. What you are asking is for someone to do your homework for you.