Re: Deriving from concrete types
In article <1151341397.479598.271680@c74g2000cwc.googlegroups.com>, Alan
McKenney <alan_mckenney1@yahoo.com> writes
True.
But if you want all the std::vector<> member functions, how is this
better than just using public inheritance?
A disadvantage of putting in "using" declarations for every
std::vector function is that it's an opportunity for errors and
omissions.
It is also an opportunity to consider what you actually need even if
that takes some time. One problem with public derivation is shown by:
#include "my_derived_vector.h"
std::vector<int> & foo(std::vector<int> );
int main(){
my_derived_vector<int> test;
my_derived_vector<int> & = foo(test);
// note foo treats test as a std::vector<int> in addition to the
return
problem
};
That just touches the edge of the coding problems once you start
publicly inheriting from standard containers.
--
Francis Glassborow ACCU
Author of 'You Can Do It!' and "You Can Program in C++"
see http://www.spellen.org/youcandoit
For project ideas and contributions: http://www.spellen.org/
youcandoit/projects
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]