Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 2005 > BOOK: Beginning Visual C# 2005
| 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 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 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.



 
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




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





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