
Class Features 89
int main()
{
int brickNo=1000; // brick number starts from 1000
CuboidMetal c1 ("Silver",3,4,12,13,1512,10.5,brickNo++);
if(c1.getSuccess())
c1.DeterminePurity(); // DisplayData function associated with c1
}
Output
Compilation error.
The reason for the compilation error is that the assignment is not allowed in case of a const
member. Then, can const data attributes associated with a class (i.e. all objects of same class) be
initialized? Yes, it is possible by using the initialisation list as follows.
CuboidMetal(char*n,float l,float b,float h, float hy ,float m,float a, const long num):brickNo(num)
{
bSuccess=false;
if( l > 0 ...