Click here to Skip to main content
15,922,166 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: problem about variable scope Pin
HeartFriend7-Apr-05 19:06
HeartFriend7-Apr-05 19:06 
GeneralRe: problem about variable scope Pin
cmk7-Apr-05 19:45
cmk7-Apr-05 19:45 
GeneralRe: problem about variable scope Pin
Michael Dunn7-Apr-05 20:28
sitebuilderMichael Dunn7-Apr-05 20:28 
GeneralRe: problem about variable scope Pin
S. Senthil Kumar7-Apr-05 21:58
S. Senthil Kumar7-Apr-05 21:58 
Questionhow to check if a reference is NULL Pin
ng kok chuan7-Apr-05 17:07
ng kok chuan7-Apr-05 17:07 
AnswerRe: how to check if a reference is NULL Pin
Ryan Binns7-Apr-05 18:14
Ryan Binns7-Apr-05 18:14 
GeneralRe: how to check if a reference is NULL Pin
ng kok chuan7-Apr-05 20:50
ng kok chuan7-Apr-05 20:50 
GeneralRe: how to check if a reference is NULL Pin
S. Senthil Kumar7-Apr-05 22:13
S. Senthil Kumar7-Apr-05 22:13 
To quench your thirst for knowledge Smile | :)
class Foo
{
   int x,y;
   public Foo(int _x, int _y) : x(_x), y(_y)
   {}
}

And there are a few reasons to prefer this syntax to manually assigning values to members. For one, if you are initializing const or reference members, you'd have to use the above syntax. Two, using the above syntax is more efficient. If you use manual member assignment, there will be two calls (constructor and operator=) for every non-POD member, if you use the above syntax, there will be only one. For eg,
class Foo
{
   string x;
   public Foo(string y) : x(y) {}
}

There will be only constructor call to string with the above syntax, as the compiler calls string(const string &) for initializing x. If you do
class Foo
{
   string x;
   public Foo(string y)
   {
     x = y;
   }
}

there will be two, string() and operator=() on string.

Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
QuestionHow to HitTest an item of a List Ctrl owned by another thread Pin
Luckybird7-Apr-05 16:23
Luckybird7-Apr-05 16:23 
AnswerRe: How to HitTest an item of a List Ctrl owned by another thread Pin
Ryan Binns7-Apr-05 18:18
Ryan Binns7-Apr-05 18:18 
GeneralRe: How to HitTest an item of a List Ctrl owned by another thread Pin
Luckybird7-Apr-05 23:29
Luckybird7-Apr-05 23:29 
GeneralRe: How to HitTest an item of a List Ctrl owned by another thread Pin
Ryan Binns8-Apr-05 2:12
Ryan Binns8-Apr-05 2:12 
Generalpliz help me with input validation Pin
mpapeo7-Apr-05 15:05
mpapeo7-Apr-05 15:05 
GeneralRe: pliz help me with input validation Pin
Christian Graus7-Apr-05 15:14
protectorChristian Graus7-Apr-05 15:14 
GeneralRe: pliz help me with input validation Pin
Anonymous7-Apr-05 15:35
Anonymous7-Apr-05 15:35 
GeneralRe: pliz help me with input validation Pin
Christian Graus7-Apr-05 15:39
protectorChristian Graus7-Apr-05 15:39 
GeneralRe: pliz help me with input validation Pin
mpapeo7-Apr-05 15:50
mpapeo7-Apr-05 15:50 
GeneralRe: pliz help me with input validation Pin
Christian Graus7-Apr-05 15:52
protectorChristian Graus7-Apr-05 15:52 
GeneralRe: pliz help me with input validation Pin
mpapeo8-Apr-05 1:48
mpapeo8-Apr-05 1:48 
GeneralRe: pliz help me with input validation Pin
David Crow8-Apr-05 5:29
David Crow8-Apr-05 5:29 
GeneralRe: pliz help me with input validation Pin
LighthouseJ7-Apr-05 15:48
LighthouseJ7-Apr-05 15:48 
GeneralRe: pliz help me with input validation Pin
mpapeo7-Apr-05 15:59
mpapeo7-Apr-05 15:59 
GeneralRe: pliz help me with input validation Pin
mpapeo7-Apr-05 16:21
mpapeo7-Apr-05 16:21 
Generalemulating commands in c++ Pin
Jeb997-Apr-05 14:32
Jeb997-Apr-05 14:32 
GeneralRe: emulating commands in c++ Pin
Christian Graus7-Apr-05 15:14
protectorChristian Graus7-Apr-05 15: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.