Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C++ and Visual C++ > BOOK: Beginning Visual C++ 6
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning Visual C++ 6
This is the forum to discuss the Wrox book Beginning Visual C++ 6 by Ivor Horton; ISBN: 9780764543883
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Visual C++ 6 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Display Modes
  #1 (permalink)  
Old September 5th, 2012, 01:25 PM
Registered User
Points: 5, Level: 1
Points: 5, Level: 1 Points: 5, Level: 1 Points: 5, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Example EX8_10 Constructor Overloading

I am using Microsoft Visual C++ 2010 Express
I am getting error

1>------ Build started: Project: EX8_10, Configuration: Debug Win32 ------
1> EX8_10.cpp
1>EX8_10.cpp(36): warning C4520: 'CBox' : multiple default constructors specified
1>EX8_10.cpp(54): error C2668: 'CBox::CBox' : ambiguous call to overloaded function
1> EX8_10.cpp(19): could be 'CBox::CBox(void)'
1> EX8_10.cpp(12): or 'CBox::CBox(double,double,double)'
1> while trying to match the argument list '(void)'
1> This diagnostic occurred in the compiler generated function 'void CBox::__dflt_ctor_closure(void)'
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

What is generated function 'void CBox::__dflt_ctor_closure(void)'
and why is it having a problem with the overloaded constructor?

The rest of the program is not having a problem with the constructors.

=======================================
Forget it - I shoud have checked Errata first.
======================================

Also the available download of example code for the book does not have the error corrected as specified in errata:

310 Page 310: Arrays of Class Objects
The constructor definition in Exercise 8_10 should read:
CBox(double lv, double bv = 1.0, double hv = 1.0): m_Length(lv), m_Breadth(bv), m_Height(hv)
=======
{
cout << endl << "Constructor called.";
}

The code shown in the book causes ambiguity over which constructor should be called, giving rise to the compiler errors described on page 295. In the code in the book, both constructors could be used to initialize the data members of the CBox objects in the array boxes. If a default value for lv is not supplied in the first constructor, the compiler knows it cannot use that constructor for the initialization and so uses the default constructor.

Last edited by RichS727; September 5th, 2012 at 06:28 PM. Reason: Code download has the same error as in the book
 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Having problem in operator overloading nimvc BOOK: Professional C++ 1 March 29th, 2010 09:33 PM
Overloading dotnetDeveloper ASP.NET 3.5 Basics 1 March 4th, 2009 03:19 PM
Overloading nayeem69 .NET Framework 2.0 1 July 17th, 2007 01:30 AM
Overloading Overriding arv1980 VS.NET 2002/2003 2 January 22nd, 2006 12:55 AM
Overloading Initialize_Class sg48 Excel VBA 1 July 11th, 2003 08:47 AM



All times are GMT -4. The time now is 10:54 AM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.