473,385 Members | 1,333 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Accelarated C++ doubt.

Hi all,

I have got a doubt in Koenig& Moo's AC++.
On page 228 and 230, authors provide definitions for Core and Grad
classes. Grad IS-A Core, i.e. public inheritance.
What puzzles me is that both have a non-virtual read member function
in the public interface.
std::istream& read(std::istream&);
It goes against the usual norm to not redefine non-virtual member
functions in derived classes (Meyers Item#37.)

Syntactically it's fine but I am suspecting if I got the authors'
wrong.
Am I missing on something?

Thanks,
Ol' Monk
Jul 22 '05 #1
3 1360
* Old Monk:

I have got a doubt in Koenig& Moo's AC++.
On page 228 and 230, authors provide definitions for Core and Grad
classes. Grad IS-A Core, i.e. public inheritance.
What puzzles me is that both have a non-virtual read member function
in the public interface.
std::istream& read(std::istream&);
It goes against the usual norm to not redefine non-virtual member
functions in derived classes (Meyers Item#37.)


Why should they redefine non-virtual member functions in derived
classes?

And since they're doing exactly that (according to you) your comment
doesn't seem to make much sense?

Can you give a link to Meyer's item #37, or if not, perhaps a quote?

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Jul 22 '05 #2
Old Monk wrote:
I have got a doubt in Koenig& Moo's AC++.
On page 228 and 230, authors provide definitions for Core and Grad
classes. Grad IS-A Core, i.e. public inheritance.
What puzzles me is that both have a non-virtual read member function
in the public interface.
std::istream& read(std::istream&);
It goes against the usual norm to not redefine non-virtual member
functions in derived classes (Meyers Item#37.)

Syntactically it's fine but I am suspecting if I got the authors'
wrong.
Am I missing on something?


Probably the fact that a recommendation is just that, a recommendation.
You don't have to follow it, if that suits your purpose.

Unless it's a hard rule written in the language Standard (like "thou
shalt not dereference a null pointer"), not following it does _not_
make it wrong. It's up to you to understand why certain rules exist
and conduct your programming activities accordingly. It's called
_freedom_ and it comes with the understanding of the consequences.

Getting to the item #37, defining a certain function in a class may
be a requirement for using that function through a template, i.e. not
necessarily polymorphically. If the behaviour of the class must change
but the function is not virtual, there is no other way but to redefine
it.

Do not take everything you read literally.

Victor
Jul 22 '05 #3
In article <a1**************************@posting.google.com >, Old Monk
<wv********@hotmail.com> writes
Hi all,

I have got a doubt in Koenig& Moo's AC++.
On page 228 and 230, authors provide definitions for Core and Grad
classes. Grad IS-A Core, i.e. public inheritance.
What puzzles me is that both have a non-virtual read member function
in the public interface.
std::istream& read(std::istream&);
It goes against the usual norm to not redefine non-virtual member
functions in derived classes (Meyers Item#37.)

Syntactically it's fine but I am suspecting if I got the authors'
wrong.
Am I missing on something?


Read a few more pages. However the thing that I would have an issue with
is their use of protected data. Protected data buys too little.
--
Francis Glassborow ACCU
Author of 'You Can Do It!' see http://www.spellen.org/youcandoit
For project ideas and contributions: http://www.spellen.org/youcandoit/projects
Jul 22 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Guilherme Pinto | last post by:
Hello. I am reading the book written by Bjarne Stroustrup called " The C++ Programming Language - Special Edition" and had a doubt which a think is really important to distinguish between the...
138
by: ambika | last post by:
Hello, Am not very good with pointers in C,but I have a small doubt about the way these pointers work.. We all know that in an array say x,x is gonna point to the first element in that...
4
by: dam_fool_2003 | last post by:
I am just a beginner in tree data – struct. I have this little doubt. Left node ‘weights' lesser than the right one. I have seen, so far it is algorithm implementations. But why not vice-versa that...
20
by: maadhuu | last post by:
firstly, i am thankful to all those who answered the 1st set of doubts. And i am not yet enlightened to that extent , coz ' i keep getting doubts. is the following defined in the language ?? int...
77
by: muttaa | last post by:
Hello all, My doubt is going to be so primitive that i ask you all to forgive me beforehand.... Here's the code snippet: int main() { int x=5;
11
by: Bob Nelson | last post by:
I don't remember seeing the term ``doubt'' used much in c.l.c. back in the 90's. When did this word become nearly synonymous with ``question'' or ``query'' and does it have static duration?
122
by: ivan | last post by:
hi all, if I have: if(A && B || C) which operation gets executed first? If I remeber well should be &&, am I correct? thanks
5
by: Paulo | last post by:
Hi, I have a RadioButtonList and I need to do some verifications on a "OnChange" event on client... because on classic asp/html I just add a "onChange" event on <input type="radio" onChange="">,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.