Click here to Skip to main content
15,888,454 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: VAssistX Pin
toxcct1-Feb-06 6:52
toxcct1-Feb-06 6:52 
GeneralRe: VAssistX Pin
RChin1-Feb-06 7:14
RChin1-Feb-06 7:14 
GeneralRe: VAssistX Pin
toxcct1-Feb-06 7:15
toxcct1-Feb-06 7:15 
GeneralRe: VS 2003 issue Pin
Prakash Nadar1-Feb-06 16:51
Prakash Nadar1-Feb-06 16:51 
JokeRe: VS 2003 issue Pin
toxcct1-Feb-06 21:56
toxcct1-Feb-06 21:56 
JokeRe: VS 2003 issue Pin
Owner drawn2-Feb-06 17:33
Owner drawn2-Feb-06 17:33 
QuestionWhat's the difference? Pin
tas28261-Feb-06 5:34
tas28261-Feb-06 5:34 
AnswerRe: What's the difference? Pin
Rama Krishna Vavilala1-Feb-06 5:58
Rama Krishna Vavilala1-Feb-06 5:58 
It is better to use the contructor syntax.

1. It is the only way to initialize reference member variables in your class. If you have any.

2. Let's say you have an object that has two contructors defined as

class A
{
public:
  A()
  {
    DoSomeStuff();
  }
  
  A(int x)
  {
    DoSomeStuff(x);
  }
 
  A& operator = (int x)
  {
     Cleanup();
     DoSomeStuff(x);
  }
};


Now lets say you want to contain an object of this class in another class.
class B
{
private:
  A a;
};


You can initialize in two ways

B::B()
  : a(5)
{
}


or

B::B()
{
  a = 5;
}


If you are not initializing the object in the constructor initialization list like that in the second case. The object will be initialized using the default constructor i.e. DoSomeStuff will be called and then when the contrsuctor code within the block gets processed the assignment operator will be called. In the first case only the constructor of A that takes int argument gets called.
GeneralRe: What's the difference? Pin
tas28261-Feb-06 6:10
tas28261-Feb-06 6:10 
GeneralRe: What's the difference? Pin
Nish Nishant1-Feb-06 6:13
sitebuilderNish Nishant1-Feb-06 6:13 
GeneralRe: What's the difference? Pin
tas28261-Feb-06 6:18
tas28261-Feb-06 6:18 
GeneralRe: What's the difference? Pin
Nish Nishant1-Feb-06 6:12
sitebuilderNish Nishant1-Feb-06 6:12 
AnswerRe: What's the difference? Pin
David Crow1-Feb-06 6:29
David Crow1-Feb-06 6:29 
AnswerRe: What's the difference? Pin
tas28261-Feb-06 6:41
tas28261-Feb-06 6:41 
GeneralRe: What's the difference? Pin
Ryan Binns1-Feb-06 17:42
Ryan Binns1-Feb-06 17:42 
AnswerRe: What's the difference? Pin
Eric Jacobsen1-Feb-06 10:49
Eric Jacobsen1-Feb-06 10:49 
AnswerRe: What's the difference? Pin
Owner drawn1-Feb-06 16:59
Owner drawn1-Feb-06 16:59 
QuestionExporting dialog resources Pin
tas28261-Feb-06 5:12
tas28261-Feb-06 5:12 
AnswerRe: Exporting dialog resources Pin
David Crow1-Feb-06 5:15
David Crow1-Feb-06 5:15 
GeneralRe: Exporting dialog resources Pin
tas28261-Feb-06 5:41
tas28261-Feb-06 5:41 
AnswerRe: Exporting dialog resources Pin
Maximilien1-Feb-06 5:55
Maximilien1-Feb-06 5:55 
QuestionFont size: point ang logic Pin
includeh101-Feb-06 4:47
includeh101-Feb-06 4:47 
AnswerRe: Font size: point ang logic Pin
Shog91-Feb-06 15:55
sitebuilderShog91-Feb-06 15:55 
Questionwhen to upgrade vc6? Pin
ehh1-Feb-06 4:16
ehh1-Feb-06 4:16 
AnswerRe: when to upgrade vc6? Pin
David Crow1-Feb-06 5:14
David Crow1-Feb-06 5:14 

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.