Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enum in C++: how to pass as parameter?

Tags:

c++

enums

class

I have in my class definition the following enum:

static class Myclass {
     ...
  public:    
     enum encoding { BINARY, ASCII, ALNUM, NUM };
     Myclass(Myclass::encoding);
     ...
}

Then in the method definition:

Myclass::Myclass(Myclass::encoding enc) {
    ...
}

This doesn't work, but what am I doing wrong? How do I pass an enum member correctly, that is defined inside a class for member methods (and other methods as well)?

like image 596
polemon Avatar asked Mar 18 '11 19:03

polemon


1 Answers

I'm not entirely sure why you're using "static class" here. This boilerplate works just fine for me in VS2010:

class CFoo
{
public:
    enum Bar { baz, morp, bleep };
    CFoo(Bar);
};

CFoo::CFoo(Bar barIn)
{
    barIn;
}
like image 123
paulcam Avatar answered Oct 11 '22 04:10

paulcam