Solved

call to default constructor from another constructor

Posted on 2003-11-28
1
270 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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

758 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now