[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 287
  • Last Modified:

call to default constructor from another constructor

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
amakalski
Asked:
amakalski
1 Solution
 
jkrCommented:
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now