Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C# 2005 > BOOK: Beginning Visual C# 2005
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning Visual C# 2005
This is the forum to discuss the Wrox book Beginning Visual C# 2005 by Karli Watson, Christian Nagel, Jacob Hammer Pedersen, Jon D. Reid, Morgan Skinner, Eric White; ISBN: 9780764578472
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Visual C# 2005 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
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 11th, 2006, 09:46 PM
Registered User
 
Join Date: Jun 2006
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default ch9:Constructor Execution Sequence

I purchased this book yesterday, when i read Constructor Execution Sequence in chapter 9. in this book write these:
If you use a nondefault constructor of a class, then the default behavior is to use a constructor on the base class that matches the signature of this constructor. If none is found, then the default constructor for the base class is used (which will always happen for the ultimate root System.Object, because this class has no nondefault constructors).
and write my code just as in the book:
    class BaseClass
    {
        public BaseClass()
        {
            Console.WriteLine("BaseClass()...");
        }
        public BaseClass(int i)
        {
            Console.WriteLine("BaseClass(int i)...");
        }

    }
    class DerivedClass:BaseClass
    {
        public DerivedClass(int i)
        {
            Console.WriteLine("DerivedClass(int i)...");
        }
    }

    class TestConstructor
    {
        public static void Main()
        {
            DerivedClass dc1 = new DerivedClass(1);
        }
    }
run,while the output is:
BaseClass()...
DerivedClass(int i)...
not the result expected as in the book:
BaseClass(int i)...
DerivedClass(int i)...

Am I doing something wrong? Or the author doesn't run their own example?
Help will be really appreciated.



Reply With Quote
  #2 (permalink)  
Old October 30th, 2006, 04:01 PM
Wrox Author
 
Join Date: Dec 2003
Location: Birmingham, , United Kingdom.
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

You are correct, the defaut behavior is to call the default constructor for the base class, as is decribed in the C# language specification 10.10.1.

I can only apologise for this, and assure you that at some point in the past the behaviour was as written here. I'm sorry if this has caused any difficulties in your understanding of this topic.

Please let me know of any more mistakes like this that you find, and I'll do my best to erradicate them all from future editions.

Cheers,

Karli

----------
www.karliwatson.com
IT Specialist & Author
Technical Director, www.3form.net
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
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
Error in Monthly Calendar Report (Ch9) mruschetti BOOK: Expert Access 2007 Programming ISBN 978-0-470-17402-9 6 May 7th, 2008 11:43 PM
VB Ch9 Try It Out Looping ... p325 Rich57 BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 2 March 7th, 2008 04:57 AM
Ch9 charlist.php undefined index grambell23 BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 2 July 7th, 2006 08:39 PM
CH9 - Apache not using custom error page d2nash BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 3 June 20th, 2006 11:25 AM
Multidimensional array in ch9 willburke BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 0 November 2nd, 2004 04:44 PM



All times are GMT -4. The time now is 04:37 AM.


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