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
1
Expert's answer
2012-12-19T10:21:35-0500
#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

Assignment Expert
02.04.21, 10:30

Dear Hamna please post a new question

Hamna
02.04.21, 10:28

Define a class named as Vehicle Contain data members(Minimum 3) Color, Wheels etc. Contain member functions( Minimum 3) Include a prototype and def of copy constructor A default constructor An Overloaded constructor No Need to define the functions Call the functions using OmniBus in main and use overloaded constructors to set values. Use copy constructors to make copy of OmniBus to a constructor SchoolBus

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS