gandhigcpp
gandhigcpp

Reputation: 587

use of the enum name

If someone uses enum name as follows:

class Logger
{
 public:
           enum LEVEL
           {
               Debug,
               Warning,
               Notification,
               Error
           };
};

What would this thing mean here:

Logger(LEVEL);

Upvotes: 2

Views: 532

Answers (2)

Tabrez Ahmed
Tabrez Ahmed

Reputation: 2960

LEVEL is an enum, It means that LEVEL can only be of values Debug, Warning,Notification, or Error. Logger(LEVEL); is a call to constructor Logger() of the class Logger that accepts values only from among Debug, Warning,Notification, and Error as its first parameter and probably initializes the property LEVEL to the value supplied.

Upvotes: 0

Kerrek SB
Kerrek SB

Reputation: 477580

This looks like the declaration of a constructor, to be used like this:

struct Logger
{
    enum LEVEL { Debug, Warning, Notification, Error };
    Logger(LEVEL);
    // ...
};

Logger wlogger(Logger::Warning);
Logger elogger(Logger::Error);

Upvotes: 4

Related Questions