64 693
Assignments Done
99,3%
Successfully Done
In September 2018

Answer to Question #20758 in C++ for ahamed

Question #20758
create aclass that imitates part of functionality of the basic data type int call the class int. the only data in this class is an int variable. include member functions to initialize an int to 0,to initialize it to an int value to display it and to add two int values


write aprogram that exercises this class by creating two initialized values and placing the response in the uninitialized value and then displaying this result

with flowchart and algorithm
Expert's answer
#include <iostream>
using namespace std;

class Int {
private:
int k1,k2;

public:
Int(int _k1, int _k2):k1(_k1),k2(_k2){};
void print();
};

void Int::print(){
cout<<k1<<" quot;<<k2;
}

int main(int argc, const char * argv[])
{
int k1,k2;
cin>>k1>>k2;
Int obj(k1,k2);
obj.print();

return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions