class intArray {
friend ostream& operator<<(ostream& outStream, intArray& rhs);
public:
intArray();
intArray(const intArray&);
~intArray();
void Print();
int Size();
int operator[](int);
intArray operator=(intArray &);
intArray operator+(intArray);
bool operator==(intArray);
private:
int size;
int *data;
};
//const member function- which ensures that values of data
members of class cant be modified
class intArray {
friend ostream& operator<<(ostream& outStream, intArray& rhs);
public:
intArray(); //cant be declared as const since it initializes values of data members of class
intArray(const intArray&);//cant be declared as const since it copies data from one object to another object
~intArray();
void Print();//can be declared as const since it only displays the data for object but doesn't modify it
int Size(); //can be declared as const since it only returns the size
int operator[](int);//can be declared as const since it only returns the value at particular position
intArray operator=(intArray &);//cant be declared as const since it copies data from one object to another object
intArray operator+(intArray);////cant be declared as const since it adds the objects
bool operator==(intArray);//can be declared as const since only comparison of objects is done
private:
int size;
int *data;
};
The following member functions can be const qualified
void Print() const
int Size() const
int operator[](int) const
bool operator==(intArray) const
Get Answers For Free
Most questions answered within 1 hours.