Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C++ and Visual C++ > Visual C++
|
Visual C++ Questions specific to Microsoft's Visual C++. For questions not specific to this Microsoft version, use the C++ Programming forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual C++ section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 17th, 2003, 03:51 PM
Registered User
 
Join Date: Sep 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Constructor With a Default?


If I have a constructor with a default defined as:

CCandyBox(char* str = "Candy")
{
...
}

And I define an object without an argument list "CCandyBox myCandyBox;" does this constructor get called?

 
Old September 18th, 2003, 05:13 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 453
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via AIM to Ankur_Verma Send a message via MSN to Ankur_Verma
Default

It does get called in this case if that is all you
wanna know.
 
Old September 18th, 2003, 02:16 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Technically, yes... but you'll get compiler errors if you have a default constructor defined (one that takes no parameters), or any other constructors whose parameters have default values.


Take care,

Nik
http://www.bigaction.org/





Similar Threads
Thread Thread Starter Forum Replies Last Post
Returning Nothing from a constructor Imar Pro VB.NET 2002/2003 8 June 29th, 2012 02:00 PM
Constructor nayeem69 .NET Framework 2.0 1 July 17th, 2007 12:33 AM
Why default constructor may be invoked? enin C# 1 July 26th, 2006 07:26 AM
Constructor ramess C++ Programming 1 March 18th, 2006 07:23 PM
Constructor problem yengzhai C++ Programming 6 May 18th, 2005 11:05 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.