Answer to Question #221394 in C++ for man18_

Question #221394

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. 


1
Expert's answer
2021-07-29T23:33:37-0400
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);
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS