Friend, Operator Overloading
Friend, Operator Overloading
double Volume() {
return length * breadth * height;
}
static int getCount() {
return objectCount;
}
private:
double length; // Length of a box
double breadth; // Breadth of a box
double height; // Height of a box
};
int main(void) {
// Print total number of objects before creating object.
cout << "Inital Stage Count: " << Box::getCount() <<
endl;
return 0;
}
Inital Stage Count: 0
Constructor called.
Constructor called.
Final Stage Count: 2