Click here to Skip to main content
15,912,932 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: how compiler differentiates inline virtual function? Pin
CPallini25-Aug-11 3:27
mveCPallini25-Aug-11 3:27 
GeneralRe: how compiler differentiates inline virtual function? Pin
Niklas L25-Aug-11 21:36
Niklas L25-Aug-11 21:36 
GeneralRe: how compiler differentiates inline virtual function? Pin
CPallini25-Aug-11 21:50
mveCPallini25-Aug-11 21:50 
GeneralRe: how compiler differentiates inline virtual function? Pin
Stefan_Lang25-Aug-11 22:31
Stefan_Lang25-Aug-11 22:31 
There are two rather common examples where virtual functions are resolved statically, and therefore can be inlined without problem:

1. Explicitely calling the base class implementation
2. Virtual destructors. The compiler will automatically create a chain of calls to destructors according to the inheritance chain. These are resolved statically. The only thing that may be resolved dynamically (at runtime) is the top level call, and even that only if the compiler cannot determine the actual class at compile time
class Shape {
   bool state;
public:
   inline virtual void initialize() {
      state = false;
   }
   inline virtual ~Shape() {} // will always be resolved statically!
};

class Square : public Shape {
   float width;
public:
   virtual void initialize() {
      Shape::initialize(); // resolved statically - this can be inlined!
      width = 0.;
   }
   ~inline virtual ~Square() {} // may be resolved statically
};

int main() {
   Shape* pShape = new Square;
   pShape->initialize;
   delete pShape; // calls pShape->Shape::~Shape() and then pShape->Square::~Square()
                  // this can be resolved statically since the compiler at this point knows the type
   return 0;
}

AnswerRe: how compiler differentiates inline virtual function? Pin
Stefan_Lang25-Aug-11 3:34
Stefan_Lang25-Aug-11 3:34 
QuestionHow to get attachment filename without download attachment file? Pin
R_K25-Aug-11 2:39
R_K25-Aug-11 2:39 
QuestionRe: How to get attachment filename without download attachment file? Pin
MicroVirus25-Aug-11 2:41
MicroVirus25-Aug-11 2:41 
AnswerRe: How to get attachment filename without download attachment file? Pin
R_K25-Aug-11 5:24
R_K25-Aug-11 5:24 
GeneralRe: How to get attachment filename without download attachment file? Pin
enhzflep25-Aug-11 6:43
enhzflep25-Aug-11 6:43 
QuestionProblem in accessing virtual hard as local hard disk Pin
Chattha1125-Aug-11 1:27
Chattha1125-Aug-11 1:27 
AnswerRe: Problem in accessing virtual hard as local hard disk Pin
Code-o-mat25-Aug-11 7:42
Code-o-mat25-Aug-11 7:42 
Questiondetect memory leak Pin
zon_cpp25-Aug-11 0:09
zon_cpp25-Aug-11 0:09 
GeneralRe: detect memory leak Pin
Rage25-Aug-11 0:22
professionalRage25-Aug-11 0:22 
AnswerRe: detect memory leak Pin
Alan Balkany25-Aug-11 5:07
Alan Balkany25-Aug-11 5:07 
AnswerRe: detect memory leak Pin
Pravin Patil, Mumbai25-Aug-11 20:37
Pravin Patil, Mumbai25-Aug-11 20:37 
AnswerRe: detect memory leak Pin
Cheongwadae26-Aug-11 16:55
Cheongwadae26-Aug-11 16:55 
QuestionHow to increate network transfer speed? Pin
yu-jian24-Aug-11 21:33
yu-jian24-Aug-11 21:33 
AnswerRe: How to increate network transfer speed? Pin
enhzflep24-Aug-11 21:45
enhzflep24-Aug-11 21:45 
AnswerRe: How to increate network transfer speed? Pin
xrg_soft@163.com24-Aug-11 21:55
xrg_soft@163.com24-Aug-11 21:55 
AnswerRe: How to increate network transfer speed? Pin
Charles Oppermann26-Aug-11 10:40
Charles Oppermann26-Aug-11 10:40 
QuestionCFormView control sizing Pin
Manmohan2924-Aug-11 21:33
Manmohan2924-Aug-11 21:33 
AnswerRe: CFormView control sizing [modified] Pin
xrg_soft@163.com24-Aug-11 21:52
xrg_soft@163.com24-Aug-11 21:52 
GeneralRe: CFormView control sizing Pin
Manmohan2924-Aug-11 22:33
Manmohan2924-Aug-11 22:33 
GeneralRe: CFormView control sizing [modified] Pin
xrg_soft@163.com25-Aug-11 4:10
xrg_soft@163.com25-Aug-11 4:10 
GeneralRe: CFormView control sizing Pin
Manmohan2925-Aug-11 19:42
Manmohan2925-Aug-11 19:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.