GIven a class definition:
class Circle
{
private:
int radius;
public:
Circle (int inputRadius)
{ radius = inputRadius; }
}
Please provide 2 distinct ways to create circle_object with initial radius value = 5.
class Circle
{
private:
int radius;
public:
Circle (int inputRadius)
{ radius = inputRadius; }
}
int main()
{
// passing the address of the calling object when the function is called
Circle circle_object;
circle_object.Circle(5);
// Creating object using pointer
Circle *circle_object;
circle_object ->Circle(5);
}
Comments
Leave a comment