Wrox Programmer Forums
|
BOOK: Professional C++
This is the forum to discuss the Wrox book Professional C++ by Nicholas A. Solter, Scott J. Kleper; ISBN: 9780764574849
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional 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 March 11th, 2009, 11:46 PM
Registered User
 
Join Date: Mar 2009
Posts: 7
Thanks: 0
Thanked 1 Time in 1 Post
Default An error found on page 255?

Hi,
(大家好!我是一名来自中国的学生。)
I am a freshman from China.
Last week I bought this book.
It is a perfectly advanced C++ textbook.
But I meet some questions when reading.
for example, on page 255.
The author said that "There is a case where you actually can change the argument list for an overridden method. The trick is that the new argument list must be compatible with the old one."
I tried but failed. The code is as below, and compiler is Microsoft Visual Studio 2008
////////////////////////////
Code:
class Super
{
public:
    Super(){}
    virtual void someMethod() {
        cout<<"in Super class"<<endl;
    }
};

class Sub : public Super
{
public:
    Sub(){}
    virtual void someMethod( int i = 2 )    {
        cout<<"in Sub class "<<i<<endl;
    }
};
int main()
{
    Sub mySub;
    Super& ref = mySub;
    ref.someMethod();
 //  calls the function in Super class!!!
//  Polymorphism does not work!
   return 0;
}
I guess override and polymorphism must satisfy several conditions:
first, the function signature must be exactly same, or
the return type is covariant;
second, of course, virtual keyword is necessary;
so the actually function call bind occurs in runtime, not compile time.

but overload occurs in compile time, because the compiler just append parameters in function name, so the function fun(int i) maybe fun_i, and fun(char ch) may be fun_c;

In this example above, the Sub class just define another function, not override the correspond function in Super class.

Last edited by bert; March 11th, 2009 at 11:48 PM..
 
Old March 12th, 2009, 12:11 AM
Registered User
 
Join Date: Mar 2009
Posts: 7
Thanks: 0
Thanked 1 Time in 1 Post
Default

anybody here?
(oh...I am sorry, now is midnight in your country, here is 13:41, or 1:41PM)
the quick reply does not support firefox?

Last edited by bert; March 12th, 2009 at 01:41 AM..
 
Old March 12th, 2009, 12:22 AM
Registered User
 
Join Date: Mar 2009
Posts: 7
Thanks: 0
Thanked 1 Time in 1 Post
Default

I have some questions to consult the respected authors:

How about the portability of SGI STL?
the book about STL, by Matthew H. Austern,Generic Programming and the STL

Is this book an elementary textbook?
and are there any source code analysis in this book?
I don't know whether this book fit me.


Thank you for your patience and kind suggestion!

Last edited by bert; March 12th, 2009 at 01:00 AM..
 
Old March 12th, 2009, 07:36 AM
jminatel's Avatar
Wrox Staff
Points: 18,059, Level: 58
Points: 18,059, Level: 58 Points: 18,059, Level: 58 Points: 18,059, Level: 58
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2003
Posts: 1,906
Thanks: 62
Thanked 139 Times in 101 Posts
Default

Bert: I'm tying this quick reply in FireFox 3.0.7. It works fine. What version are you using?
__________________
Jim Minatel
Associate Publisher, WROX - A Wiley Brand
Did someone here help you? Click on their post!
 
Old March 12th, 2009, 08:19 AM
Registered User
 
Join Date: Mar 2009
Posts: 7
Thanks: 0
Thanked 1 Time in 1 Post
Default

Quote:
Originally Posted by jminatel View Post
Bert: I'm tying this quick reply in FireFox 3.0.7. It works fine. What version are you using?
as below:

Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.0.7) Gecko/2009021910 Firefox/3.0.7
 
Old July 15th, 2010, 09:09 AM
Authorized User
 
Join Date: Jan 2010
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to meteormatt Send a message via Yahoo to meteormatt
Default

Quote:
Originally Posted by bert View Post
I have some questions to consult the respected authors:

How about the portability of SGI STL?
the book about STL, by Matthew H. Austern,Generic Programming and the STL

Is this book an elementary textbook?
and are there any source code analysis in this book?
I don't know whether this book fit me.


Thank you for your patience and kind suggestion!
STL is good.

But in my company, my team leader do not let me use STL.

They tell me to write my own "Vector".

This is a fact in Chinese company.





Similar Threads
Thread Thread Starter Forum Replies Last Post
The page cannot be found tbroom BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 13 August 18th, 2006 10:32 AM
Exception:Page Not found arnabghosh C# 4 December 3rd, 2005 11:43 AM
" Error" Page not found shoakat Classic ASP Databases 1 November 15th, 2004 03:59 AM
HTTP 404 Page not found hosefo81 Beginning PHP 4 October 26th, 2003 06:27 PM
Page Not Found Error ztz02 Classic ASP Basics 2 June 25th, 2003 08:52 AM





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