How to tied enum to a class
-
Lets say I have enum OutputFormat { HEX, BINARY DECIMAL } class Foo{ ... ... public void print(OutputFormat x){ .... .... } foo y = ....; y.print(OutputFormat.HEX); But I'd like to ties the enum to the class so that the call would look like y.print(Foo.OutputFormat.HEX); instead of the y.print(OutputFormat.HEX); Any ideas> Thanks
-
Lets say I have enum OutputFormat { HEX, BINARY DECIMAL } class Foo{ ... ... public void print(OutputFormat x){ .... .... } foo y = ....; y.print(OutputFormat.HEX); But I'd like to ties the enum to the class so that the call would look like y.print(Foo.OutputFormat.HEX); instead of the y.print(OutputFormat.HEX); Any ideas> Thanks
class Foo{ public enum OutputFormat { HEX, BINARY DECIMAL } ... } You can also use private to make the enum only useful within the class.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
class Foo{ public enum OutputFormat { HEX, BINARY DECIMAL } ... } You can also use private to make the enum only useful within the class.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
I'm a retard. I could swear that I retried that and got a compiling error! It works now. Thank you very much, I can stop banging my head on the desk.
dino2094 wrote:
I'm a retard.
*grin* everyone is a retard, sometimes.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )