Solved

call to default constructor from another constructor

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
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 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 use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

932 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

15 Experts available now in Live!

Get 1:1 Help Now