CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 11 of 11

Threaded View

  1. #1
    Join Date
    Jan 2006
    Posts
    384

    Class object construction process

    Code:
    #include "stdafx.h"
    int func1()
    {
    	printf("Initializing i\n");
    	return 10;
    
    }
    int func2()
    {
    	printf("Initializing j\n");
    	return 20;
    }
    class A
    {
    private :
    
    	 int j;
    	 int i;
    public:
    	A():i(func1()),j(func2())
    	{
    	}
    
    };
    
    int _tmain(int argc, _TCHAR* argv[])
    {
    	A a;
    	return 0;
    }
    What is it that causes func2() to be called before func1() in the above sample ? Is this as per the C++ specification ?
    Can you please outline the process of execution of the constructor and creation of data members during object construction ?
    Last edited by humble_learner; May 12th, 2010 at 04:26 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured