Click here to Skip to main content
15,893,588 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionHow to display the contents of the .OST file??? Pin
nagamohan_p4-Oct-06 23:04
nagamohan_p4-Oct-06 23:04 
AnswerRe: How to display the contents of the .OST file??? Pin
Manish K. Agarwal5-Oct-06 0:23
Manish K. Agarwal5-Oct-06 0:23 
GeneralRe: How to display the contents of the .OST file??? Pin
nagamohan_p5-Oct-06 6:42
nagamohan_p5-Oct-06 6:42 
AnswerRe: How to display the contents of the .OST file??? Pin
Hamid_RT6-Oct-06 8:09
Hamid_RT6-Oct-06 8:09 
GeneralImplicitly calling constructors Pin
Rob Caldecott4-Oct-06 22:23
Rob Caldecott4-Oct-06 22:23 
GeneralRe: Implicitly calling constructors Pin
Nibu babu thomas4-Oct-06 22:33
Nibu babu thomas4-Oct-06 22:33 
GeneralRe: Implicitly calling constructors Pin
wheelerbarry4-Oct-06 23:03
wheelerbarry4-Oct-06 23:03 
AnswerRe: Implicitly calling constructors Pin
prasad_som4-Oct-06 23:30
prasad_som4-Oct-06 23:30 
Rob Caldecott wrote:
For example, suppose you have a class that contains a std::string (or CString), and the strings should be empty ("") when the class is created. I have always let the compiler implicitly call the string constructor, and hence would have something that looks like this:


class foo{private: std::string str_;public: foo() /* str_ constructor implicitly called */ { }};


you are right.


Rob Caldecott wrote:
However, it has been suggested that all members should appear in the constructors initialization list, and that I should change my constructor to one of the following:


foo() : str_("")


or


foo() : str_()

In this case it doesn't make sense to initialize member variable in initialization list. Because, generally, well designed classes takes care of default initialization.
Only difference, here would hapeen is, if you doesn't use member initialization list, default c'tor will be called, and copy c'tor otherwise.

It is advised to use member initialization list, because it save assignment operator call; if you are going to assign some value to member variable.
consider this scenario,
class foo
{
CStrin m_sMyString;
public:
foo()
{
 m_sMyString = "This string i want as default"; //assignment operator
 //here m_sMyString is initialized to default value,and again,assigned to new
 // value using assignment operator
}

};
where as this is efficient,
class foo
{
CStrin m_sMyString;
public:
foo(): m_sMyString("This string i want as default") 
{
 //here m_sMyString is initialized to value we want
}

};





GeneralRe: Implicitly calling constructors Pin
David Crow5-Oct-06 3:00
David Crow5-Oct-06 3:00 
GeneralRe: Implicitly calling constructors Pin
Rob Caldecott5-Oct-06 3:04
Rob Caldecott5-Oct-06 3:04 
GeneralRe: Implicitly calling constructors Pin
David Crow5-Oct-06 3:26
David Crow5-Oct-06 3:26 
GeneralRe: Implicitly calling constructors Pin
Rob Caldecott5-Oct-06 3:15
Rob Caldecott5-Oct-06 3:15 
QuestionUsing Datagrid activeX Pin
NorGUI4-Oct-06 21:54
NorGUI4-Oct-06 21:54 
QuestionHow to control in VC6 Pin
tamasan4-Oct-06 21:37
tamasan4-Oct-06 21:37 
AnswerRe: How to control in VC6 Pin
_AnsHUMAN_ 4-Oct-06 21:45
_AnsHUMAN_ 4-Oct-06 21:45 
AnswerRe: How to control in VC6 Pin
Hamid_RT4-Oct-06 22:01
Hamid_RT4-Oct-06 22:01 
GeneralRe: How to control in VC6 Pin
tamasan4-Oct-06 22:13
tamasan4-Oct-06 22:13 
GeneralRe: How to control in VC6 Pin
Hamid_RT5-Oct-06 0:07
Hamid_RT5-Oct-06 0:07 
AnswerRe: How to control in VC6 Pin
toxcct5-Oct-06 0:02
toxcct5-Oct-06 0:02 
QuestionFtpCommand not defined in Visual Studio Pin
codepanter4-Oct-06 21:21
codepanter4-Oct-06 21:21 
AnswerRe: FtpCommand not defined in Visual Studio Pin
_AnsHUMAN_ 4-Oct-06 21:39
_AnsHUMAN_ 4-Oct-06 21:39 
AnswerRe: FtpCommand not defined in Visual Studio Pin
David Crow5-Oct-06 3:06
David Crow5-Oct-06 3:06 
QuestionChanging Dialog Template Dynamically Pin
Reji_Kumar4-Oct-06 20:21
Reji_Kumar4-Oct-06 20:21 
AnswerRe: Changing Dialog Template Dynamically Pin
Mohammad A Gdeisat4-Oct-06 23:53
Mohammad A Gdeisat4-Oct-06 23:53 
QuestionRe: Changing Dialog Template Dynamically Pin
Reji_Kumar4-Oct-06 23:55
Reji_Kumar4-Oct-06 23:55 

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.