Solved

call to default constructor from another constructor

Posted on 2003-11-28
1
276 Views
Last Modified: 2010-04-01
I have CClientSocket class and inside I have two constructors: default one and following

CClientSocket::CClientSocket(const char *pszHost, int nPort, bool bEncrypted /*= false*/)
{
 //how to call default constructor here?
}

How can I call default constructor from within second constructor ?
0
Comment
Question by:amakalski
1 Comment
 
LVL 86

Accepted Solution

by:
jkr earned 125 total points
ID: 9839055
You can't - that's why one usually creates common 'init()' methods to carry out tasks that are needed in every ctor, e.g.

CClientSocket::init()
{
// common initialization stuff
}
CClientSocket::CClientSocket()
{
    init ();
}
CClientSocket::CClientSocket(const char *pszHost, int nPort, bool bEncrypted /*= false*/)
{
    init ();

    // more stuff
}


0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
c++ how to tell if the progra is ctl or mfc atl ect 6 85
Which IDE to use to begin C++ training? 5 66
Excel/Word Add-in in what language? 5 132
C++ Language error 28 252
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question