Thursday, July 9, 2009

C++ Value of a type enumeration return as reference or output parameter?

I have a value which is of a type of enumeration and I would like to return it as a reference or output parameter in C++. As you can probably tell I know little about C++ hence the question. The following works for a char value :-


MethodA(char *name)


strcpy(name, anotherName)





However I do not know how to do this with a enumeration type.

C++ Value of a type enumeration return as reference or output parameter?
Hi,





Right then. An enumeration is simply an integer. So you treat it as one.





typedef enum


{


beer,


wine,


whiskey


} drinks;





void main()


{


drinks dave_likes, dave_got;





dave_likes = beer;





dave_got = *GetRoundIn(dave);


}





drinks* GetRoundIn(drinks dave_likes)


{


return %26amp;dave_likes;


}
Reply:I'm not sure what you're plannign to do, maybe you can give more information.





enum value_enum {...};





void methodA(value_enum e)


{


// now you can work with e


}





value_enum methodB(...)


{


// can return an enum


}
Reply:you can use the type enumeration how another type.. think to an integer ..





you can use an integer how return value, parameter, reference, pointer.. the same operations for the enumeration type.
Reply:Have you tried using this site.


http://dev.mysql.com/doc/refman/4.1/en/e...
Reply:example:


if Days will be enum type:





void ReturnDay(Days%26amp; oDay) {


oDay = Monday;


}


No comments:

Post a Comment