Class Features 155
same value x, we can write a concise statement as below in the constructor of CuboidMetal
class.
length=breadth=height=a;
This is not true in case of the member initialization list. We need to write explicitly
CuboidMetal(…….):length(a),breadth(a),height(a)….{…}
Q5. Is it possible to declare friend function as a static function?
Ans. Yes. You can declare friend function as static in Program 3.17 and simulate the results.
When any function at file scope is declared static, it cannot be accessed outside that file. Similarly,
if you declare compareVolume function as static, it cannot be accessed from other files.
Exercises
A. State True or False.
1. A constructor is used to initialize an object.
2. A constructor has the same ...