Thread: inline as constructors?

  1. #1
    Registered User
    Join Date
    Sep 2002
    Posts
    64

    inline as constructors?

    what does it mean to use an inline function for a constructor? anyone have an example?

  2. #2
    Just because ygfperson's Avatar
    Join Date
    Jan 2002
    Posts
    2,490
    an inline function is a regular function, nothing more. while regular functions are called with a "JMP" code, then "RET"urned to the next line, inline functions are copied, in their entirety, to the place which calls them

    ie:

    Code:
    void apple() {
    
      banana();
    }
    
    void banana() {
    
      printf("%c is for cookie",'c');
    }
    would become
    Code:
    void apple() {
    
      printf("%c is for cookie",'c');
    }
    inline void banana() {
     
      printf("%c is for cookie",'c');
    }

  3. #3
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    Originally posted by ygfperson
    an inline function is a regular function, nothing more. while regular functions are called with a "JMP" code, then "RET"urned to the next line, inline functions are copied, in their entirety, to the place which calls them
    Just to be pedantic, but for Intel and AMD chips the instruction to execute a function is a "CALL"...that call often goes to a jump table (often when an import table is used for a dll).....but a call is better used as it pushes the return address on the stack and without that, the "RET" instruction will send the thread of execution more or less anywhere...often ending in a crash

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. When to inline your *tors
    By Angus in forum C++ Programming
    Replies: 43
    Last Post: 10-29-2008, 03:38 PM
  2. Code review
    By Elysia in forum C++ Programming
    Replies: 71
    Last Post: 05-13-2008, 09:42 PM
  3. constructors and qualifiers
    By petermichaux in forum C++ Programming
    Replies: 6
    Last Post: 01-01-2004, 08:40 PM
  4. Certain functions
    By Lurker in forum C++ Programming
    Replies: 3
    Last Post: 12-26-2003, 01:26 AM
  5. inline??
    By bman1176 in forum C++ Programming
    Replies: 2
    Last Post: 06-25-2002, 05:31 PM