I want to return the enumerator indentifier itself, not the enumerator value. But we're supposed to be able to do that using only the one function I have written there. Am I using the wrong kind of function or what?
Printable View
I want to return the enumerator indentifier itself, not the enumerator value. But we're supposed to be able to do that using only the one function I have written there. Am I using the wrong kind of function or what?
The only way to return that - presuming you mean the string 'scalene' etc - is to use a function that returns a string.
I'm not entirely sure you're on the same planet as me otherwise.
I can kind of see what you mean, kinda.
Then apply what I showed you to your function.
Like I posted.............
And declare your function to return a string.Code:switch(type)
{
case scalene: return "scalene";
case isosceles: return "isosceles";
case equilateral: return "equilateral";
case noTriangle: return "No Triangle";
default: return "Error";
}
alright i think you are missing the point..
when you enumarate stuff it basicly puts numbers on them as i said before
Code:enum Test {zero, one, two, three};
//its just like this:
int zero = 0;
int one = 1;
//etc..
// what the enum statement does is make them like macros or int's if you will
// Zero = 0.. so lets say:
return zero;
// this is exactly the same thing as:
return 0;
// now to return the name and pirnt it out you can do what i suggested you or what JoshR suggested..
Thanks. I got it now. Sorry for seeming so dense about this stuff... I'm just learnin'.
no problem, we were all like that when we were learning.. and rememeber if you dont understand something reread it... i know that you wont actualy reread something because i never did either :pQuote:
Originally Posted by MyntiFresh
just FYI: don't worry too much about getting this whole enum thing down... you probably won't ever use it again... I once read an essay by Bjarne Stroustrup in which he said he wished enum was never part of the language because it's not very useful and doesn't fit in with the rest of the language... you can find the essay somewhere in General Discussions...
Thanks! I'm very glad to hear that. LOLQuote:
Originally Posted by major_small