|
From: jeremit0 on 16 Apr 2008 06:44 I am having an issue with passing an enum as a default argument to a class method. I have a class similar to enum Method { a, b }; class A{ A(); void MyMethod(int i, Method m = a){ ... } } The compiler error I get says error: default argument for 'Method m' has type '<unknown type>' How can I use a default argument for an enum? Thanks, Jeremy -- [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ]
From: Chris Uzdavinis on 16 Apr 2008 18:49 On Apr 16, 5:44 pm, jeremit0 <jerem...(a)gmail.com> wrote: > enum Method { a, b }; > class A{ > A(); > void MyMethod(int i, Method m = a){ > } > }; > > The compiler error I get says > error: default argument for 'Method m' has type '<unknown type>' > How can I use a default argument for an enum? That is valid code. Perhaps your compiler has a bug? -- Chris [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ]
From: Ulrich Eckhardt on 16 Apr 2008 18:59 jeremit0 wrote: > I have a class similar to > > enum Method { a, b }; > > class A{ > A(); > void MyMethod(int i, Method m = a){ > ... > } > } I guess the problem is in the 'similar to', because this code: enum method { a, b }; void function( method m = a); ...actually compiles fine. Provide the real code, stripped down to the very minimum. Uli -- Sator Laser GmbH Geschäftsführer: Michael Wöhrmann, Amtsgericht Hamburg HR B62 932 [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ]
|
Pages: 1 Prev: Please consider this addition for tuples in c++0x Next: composition and bad_alloc |