how to call a member function with a enum type parameter?

Dear all, now i have a class with a enum type variable like below:enum Disc{Red, Yellow};. And a member function like this:int addDisc(int col, Disc d);.How can i call the member function in the main function. i mean i don't know how to pass the actual parameter to it. Need i declear a new variable the same as "Disc" in the class? No matter what i do, the C++ complier syas "error C2664: 'ConnectN::addDisc' : cannot convert parameter 2 from 'int' to 'Disc'"
The type is 'Disc' and the values you can assign to it are 'Red' and 'Yellow'

1
2
3
4
5
6
7
addDisc( 0, Red );  // OK

int foo = Red;
addDisc( 0. foo ); // BAD, foo is not a Disc

Disc bar = Red;
addDisc( 0, bar );  // OK 
Last edited on
o~~~thank you very much. :) i find the problem is i deleared a new enum type variable in the main function~~~now it works~~~:)
Topic archived. No new replies allowed.