I want a clarification
struct Sphere
{
int a;
Sphere() {}
Sphere(int given)
{
a = given;
}
Sphere (const Sphere &s)
{
a=s.a;
}
};
When I do this :
Sphere mySphere;
mySphere.a = 5;
Which constructor is being called? What is the role of const
here? If I omit the const
constructor, then value of a
isn't assigned. Why is that?