So I need to construct a class that functions like an integer. I have tried several things but I am looking for a place to start because I don't know where to go. Here is what I started with:
#ifndef INT_h
#define INT_H
class INT {
public:
//ctor
INT::INT (int){ };
//end ctor
//Mods
INT & operator= (const INT &);//assign
INT & operator+ (const INT &);//Add
INT & operator- (const INT &);//Subtract
INT & operator+= (const INT &); //Add
INT & operator-= (const INT &); ;//Subtract
INT operator++ (); //Prefix
INT operator-- ();////Prefix
INT operator++ (int); //Postfix
INT operator-- (int);//Postfix
//selector
operator int () const {return 0;}
};
#endif
I added the other modifiers as suggested and corrected the defining "#ifndef INT_H". So when I assign an operator member function, is this the correct format? how should I format if not, this is wrong but I think it is close.
INT::operator* int ()
{
return ;
};
I am just having an issue trying to get formatting down, I haven't been doing any C/C++ for about 3 years and I am foggy to say the least.
One other observation. Your class defintion does not have any storage declared.
If you assign a value to an instance of your class, where will it be stored?