Home › Forums › C Programming › inline function
- This topic has 2 replies, 3 voices, and was last updated 17 years, 2 months ago by S.Thananchayan.
Viewing 2 reply threads
- AuthorPosts
- October 15, 2007 at 10:58 am #2018vishalParticipant
:o Actually i want to know about inline functions. the basic restrictions on them and where to use it. whether we can use return statement on it or not and the explanation about it.
I am following balagurusamy fo it and on page no. 84 of it they hav used return in inline. Also i want to know about the restrictions that why we can not use loops,switch or while in inline. And if possible pls give me some nice tutorial of friend functions
- October 23, 2007 at 3:30 am #3258theblingerParticipant
HI,
You can get good c++ tutorial in cplusplus.com website.Raghuram
- October 24, 2007 at 6:43 am #3259S.ThananchayanParticipant1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465#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>
- AuthorPosts
Viewing 2 reply threads
- The forum ‘C Programming’ is closed to new topics and replies.