Ask coding questions

← Back to all posts
C++ OOP help
MichelleA8 (2)

I don't know why it doesn't highlight "Circle" and "Color" as valid data types in "Circle.cpp"
• no global variables or constants, parameters and return values used for data transfer between functions, descriptive identifier names
• Modify the Circle pi instance variable to be a static member variable
called PI. This can be a constant (Note: Constant static class members
are not explicitly covered in the textbook; however, the const keyword can be used in a static class member declaration and definition to create a constant static class member).
• Add the following functionality for the Circle class:

  • Member variable of the enumerated type Color (RED = 1, WHITE =
    2, BLUE = 3). Modify constructors to set/use this additional member
    variable. Use RED as the default color. Include public accessor and
    mutator functions for this additional member variable that get/set the
    enumerated type.
    -All member variables declared private; all member functions declared
    -Include a copy constructor.
    -Member functions getArea, getDiameter, and getCircumference
    cannot be declared inline
  • Friend function displayCircle that takes a single Circle object
    parameter and uses its friend status to descriptively display the
    radius, color (RED, WHITE, or BLUE), area, diameter, and
    circumference to standard output using friendship status access for
    the member variables.
    -Non-friend and non-member function inputCircle that takes no
    parameters and uses descriptive prompts to read Circle instance data
    from user, radius and color, and then returns a Circle object created
    with user input instance data.
Answered by mwilki7 (152) [earned 5 cycles]
View Answer
mwilki7 (152)

I think that's just a repl bug

MichelleA8 (2)

@mwilki7 I'm using Visual Studio and it doesn't run properly. It says "<error-type>" in "Circle" and "Color" in "Circle.cpp"

mwilki7 (152)

@MichelleA8 I moved a function definition to your main cpp file and fixed a couple namespace errors though I can't seem to figure out what fixed the problem from repl's perspective. The includes were fine.

MichelleA8 (2)

@mwilki7 Thank you. This works.