Is there any standard for returning values from a function?
-
Hi, Is there any standard for return values from a function, for example if my function returns only two value(true/false) then i would like to assign bool as its return value, but if i have got three values(0,1,2), then what data type should be the used as return value.
Best Regards, Mushq Mushtaque Ahmed Nizamani Software Engineer Ultimus Pakistan "English is my second language, so please don't mind if i do some grammatical or spelling mistakes in my messages."
-
Hi, Is there any standard for return values from a function, for example if my function returns only two value(true/false) then i would like to assign bool as its return value, but if i have got three values(0,1,2), then what data type should be the used as return value.
Best Regards, Mushq Mushtaque Ahmed Nizamani Software Engineer Ultimus Pakistan "English is my second language, so please don't mind if i do some grammatical or spelling mistakes in my messages."
you have plenty of types. if the function may return little integers, char is good enough. but short, int, long are possible choices.
[VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]
-
Hi, Is there any standard for return values from a function, for example if my function returns only two value(true/false) then i would like to assign bool as its return value, but if i have got three values(0,1,2), then what data type should be the used as return value.
Best Regards, Mushq Mushtaque Ahmed Nizamani Software Engineer Ultimus Pakistan "English is my second language, so please don't mind if i do some grammatical or spelling mistakes in my messages."
If the function may return only a small set of integers (such as {0,1,2}) then the
enum
type is a good choiche. Usually you can assign to each member of the set a meanigful name:enum TrustLevel
{
LOW = 0,
AVERAGE,
HIGH
};If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
-
Hi, Is there any standard for return values from a function, for example if my function returns only two value(true/false) then i would like to assign bool as its return value, but if i have got three values(0,1,2), then what data type should be the used as return value.
Best Regards, Mushq Mushtaque Ahmed Nizamani Software Engineer Ultimus Pakistan "English is my second language, so please don't mind if i do some grammatical or spelling mistakes in my messages."
return int . so you can return up to 2 billion. :laugh:
dlfkgj lsdfkglfkgjlfgl jldfk fldkk jk
-
return int . so you can return up to 2 billion. :laugh:
dlfkgj lsdfkglfkgjlfgl jldfk fldkk jk
Kenan Aksoy wrote:
2 billion
That's all? What if you need more in the future? You have to think ahead, you know. :rolleyes:
Mark Salsbery Microsoft MVP - Visual C++ "Go that way, really fast. If something gets in your way, turn."
-
return int . so you can return up to 2 billion. :laugh:
dlfkgj lsdfkglfkgjlfgl jldfk fldkk jk