Problem using enum with vector?

From: BCC (a_at_b.c)
Date: 10/31/03


Date: Fri, 31 Oct 2003 02:43:38 GMT

I have a simple container class with an enum:

class MyObject {
    typedef enum {
        etype1,
        etype2
    } EType;
};

In another class I have a vector:
std::vector<MyObject::EType> type_vec;

Compiling works okay up to this point, but I need a vector of my enum types.
If I try to add one:

type_vec.push_back(MyObject::etype1);

I get a compiler error C2666 "etc etc" 2 overloads have similar conversions.

I use this enum in many places without a problem, just creating and using a
vector of them seems to be a problem.

What am I doing wrong?



Relevant Pages

  • Re: --(int)d
    ... Compiling with g++, -pedantic has no effect, the compiler happily ... Anyway let me explain what i was doing: my enum has 4 directions (say, ... Again, what's the point of!ptr if ptr is not a boolean, but a ... Pointers are to be compared to pointers, ...
    (comp.lang.c)
  • Re: Help with a macro
    ... > (enum lst start))) ... "Warning: While compiling these undefined functions were referenced: ... to use LABELS instead of FLET. ... Back to DEFENUM: LABELS will make this compile and this run: ...
    (comp.lang.lisp)
  • Re: Enumerations as case labels
    ... when compiling it with the compiler that ships ... you are using D for both the template ... parameter and the enum member name. ...
    (comp.lang.cpp)
  • Re: Problem using enum with vector?
    ... > I have a simple container class with an enum: ... > class MyObject { ... > typedef enum { ... >} EType; ...
    (comp.lang.cpp)
  • Re: Disable Compiler Waring
    ... I don't have to worry about compiling my code in other compiler. ... But I like your idea of putting/enclosing the enum declaration in a namespace. ... enum foo {bar}; ...
    (microsoft.public.vc.language)