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();
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
Thank you! Your comments have been successfully added. However, they need to be checked by the moderator before being published.
Comments
Dear Hamna please post a new question
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