if-else statement in a function

Jun 20, 2009 at 4:19am
How do you call a function (in c++) that is only composed of if-else statements and cout(s)?

I need it to be able to repeatedly display the cout statement inside my main() in order for me to shorten the number of codes and avoid using /Zm

Jun 20, 2009 at 4:32am
/Zmnumber determines the compiler's memory allocation limit for the precompiled header. number is a scaling factor with a default value of 100, which specifies a memory allocation of 50MB.

Um... What?

Call it like you would call any other function. I'm not sure what the point of this question is.
Jun 20, 2009 at 4:43am
It's for our c++ project and it has to be short and we're not allowed to use /Zm :(

The problem is I find function confusing and I don't know how to construct it correctly...

for example, I'd like to display

cout<<"I'm a c++ noob"<<endl;
cout<<"I'm a c++ noob"<<endl;
cout<<"I'm a c++ noob"<<endl;

In my switch statement but instead of typing the whole thing, I'll put it inside a function so that i could just call it whenever I need it to be displayed.

Could you give me an example?
Last edited on Jun 20, 2009 at 5:11am
Jun 20, 2009 at 9:23am
closed account (S6k9GNh0)
Holy crap, if you can't figure this out on your own, you need to either go look at a tutorial or just sit and think about ways to do this. To us, this is like asking how to run instead of walk.
Jun 20, 2009 at 12:53pm
Hmmm sorry if it's too simple for you but at least try not to act like a neanderthal... I guess TOO MUCH knowledge turns some people into asses
Jun 20, 2009 at 2:06pm
Oi, both of you. Alright, computerquip, I'll admit that you have a point, but please, try to put it more politely. karl4tich, there was no need for you to respond. Two wrongs don't make a right.

Anyway...

http://cplusplus.com/doc/tutorial/functions/

Read this; it really sheds some light on the subject.
Topic archived. No new replies allowed.