I have a TrafficLight C++ class and I have some doubts about using enum for color management, especially regarding the correct syntax to use. below I write simplified code pieces, since my intent is only to understand how it works:
class TrafficLight
{
private:
// ...
enum class color{
GREEN,
RED,
YELLOW
};
// ...
public:
TrafficLight(/* Want to pass the color here in the constructor */)
{
if(/* Color passed as argument is RED */)
// do something...
{}
else
// do something else...
{}
}
};
OtherClass
: this class creates a TrafficLight
object with a specified color:
class OtherClass
{
public:
//...
void createTrafficLight()
{
TrafficLight traffic_light(/* Color */);
}
//...
};
TrafficLIght and OtherClass are not in the same file.
I'm not sure what the syntax is for passing the color of the traffic light as an argument