Solved

call to default constructor from another constructor

Posted on 2003-11-28
1
277 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: 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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VS2015 compilation and missing DLLs 9 190
c++ substatte a varabe for a string in a LPCTSTR statment 8 100
I could not build boost code, 10 115
maximize the sum of fractions 33 74
Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
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 be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

732 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