Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C++ > Another inline ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 6 Topic 43853 of 48044
Post > Topic >>

Another inline question

by asterisc <Rares.Pop@[EMAIL PROTECTED] > Mar 12, 2008 at 03:16 PM

Hi there,

Before getting a binary, there is the following sequence of steps:
 - preprocessing
 - compilation
 - assembly
 - linking

Is there any rule at which level should the inline work?
I mean, where should we see the effect of the inline keyword ?

I have the following fairly simple piece of code:

//test.cpp
#include <iostream>

inline void increment( int& i )
{
    ++i;
}

#define INCREMENT(i) (++i)

int main()
{
    int i = 0;
    increment( i );
    std::cout << i << endl;
    INCREMENT(i);
    std::cout << i << endl;
}

The #define is replaced in the preprocessing step.

As far as I could check, the effect of the inline is only at the
assembling step, where we won't have a call to the increment()
function. (if we apply an optimization)
The preprocessed source looks exactly the same as the .cpp file, only
the #define was expanded.

Is that the normal behavior?

Another question, how is inline working with a virtual member
function? (if we call that function thru a base pointer which point to
a derived object)

Thanks in advance
 




 6 Posts in Topic:
Another inline question
asterisc <Rares.Pop@[E  2008-03-12 15:16:43 
Re: Another inline question
"Victor Bazarov"  2008-03-12 18:25:59 
Re: Another inline question
asterisc <Rares.Pop@[E  2008-03-12 15:34:48 
Re: Another inline question
Paavo Helde <nobody@[E  2008-03-12 19:02:33 
Re: Another inline question
Juha Nieminen <nospam@  2008-03-13 10:51:04 
Re: Another inline question
James Kanze <james.kan  2008-03-13 02:52:17 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed Oct 15 22:37:19 CDT 2008.