if-else statement in a function

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

/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.
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
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.
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
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.