PROBLEM

14 views
Skip to first unread message

Muhammad Rafay Abdullah

unread,
May 10, 2013, 2:57:29 PM5/10/13
to cs1003-s...@googlegroups.com
Assalam u alikum:
                          Sir/mam please explain this...


Member functions defined inside the class are handled automatically as inline functions.

Member functions that defined outside the class can be made inline by using keyword inline.

Sami Ullah Kashif

unread,
May 11, 2013, 3:11:13 AM5/11/13
to cs1003-s...@googlegroups.com
Let us say, you have the code:

Class C
{
     C() { cout<<"This is first constructor of Class C" << endl; }
     inline C(int);
};

The first constructor C() has been made inline by the compiler whether you like it or not. Basically if you implement a function within the class, it becomes inline automatically.

Now consider the second case: The function is not implemented in the class but I want to make it inline. So I have clearly written inline before it.

Regards,
Sami


Itban Saeed Usmani

unread,
May 12, 2013, 2:43:40 AM5/12/13
to cs1003-s...@googlegroups.com
For which purpose inline keyword is used? 
I mean what is its advantage?

Sami Ullah Kashif

unread,
May 12, 2013, 6:22:04 AM5/12/13
to cs1003-s...@googlegroups.com
It has to do with compiler optimizations. Don't worry about what it does.

Regards,
Sami
Reply all
Reply to author
Forward
0 new messages