Home › Forums › C Programming › inline function › Reply To: inline function
October 24, 2007 at 6:43 am
#3259
S.Thananchayan
Participant
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | #include <iostream><br /> using namespace std;<br /> void Menu();<br /> int GetSomething();<br /> inline void do_something (char* a)<br /> {<br /> cout << a << endl;<br /> }<br /> inline void do_something_else (char* b)<br /> {<br /> cout << b << endl;<br /> }<br /> inline void and_even_more (char* c)<br /> {<br /> cout << c << endl;<br /> }<br /> int main()<br /> {<br /> int loop;<br /> int z;<br /> for (loop = 0; loop < 10; loop++)<br /> do_something("Dont taze me bro");<br /> cout << "Press 1 or 2 for answer";<br /> cin >>z;<br /> if (z==1)<br /> do_something_else("now you do what they told ya");<br /> if (z==2)<br /> and_even_more("Everyone fear the machine");<br /> else<br /> <br /> Menu();<br /> <br /> int fun;<br /> fun = GetSomething();<br /> <br /> switch (fun) {<br /> case 1:<br /> std::cout << "Wee" << std::endl;<br /> break;<br /> case 2:<br /> std::cout << "Dude" << std::endl;<br /> break;<br /> case 3:<br /> std::cout << "Quitting" << std::endl;<br /> break;<br /> default:<br /> std::cout << "aInvalid selection" << std::endl;<br /> break;<br /> }<br /> return 0;<br /> }<br /> void Menu()<br /> {<br /> std::cout << "--- Menu ---" << endl;<br /> std::cout << "1=Wee" << endl;<br /> std::cout << "2=Dude" << endl;<br /> std::cout << "3=Quit" << endl;<br /> }<br /> int GetSomething()<br /> {<br /> int selection;<br /> std::cout << "Enter Selection: ";<br /> std::cin >> selection;<br /> return selection;<br /> }</iostream> |