RE: [Dev-C++] Super charging the string class
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Ioannis V. <iv...@em...> - 2003-07-04 20:24:40
|
-----Original Message-----
From: dev...@li...
[mailto:dev...@li...] On Behalf Of David =
McKen
Sent: Friday, July 04, 2003 9:34 PM
To: Dev-Cpp Mailing List
Subject: Re: [Dev-C++] Super charging the string class
I see. So sub-classing basic_string<char> would be the reccomended way =
to do
this then?
=20
With respect to the over-ridden methods I am wondering whether you have =
some
example code that I can see. I know how to call base class methods from =
a
derived class but what I need is a way to reverse the default method =
called
(usually the derived method is called, I want the base to be called, if =
one
exist)=20
=20
The concept is a bit stupid... You can check what members the =
std::string
has. anyway in general if you inherit from a class and you do not know =
what
member functions has(?!) if a member function exists, is non-virtual by =
its
creator and takes the same arguments as yours, you can use that function =
by
using a base pointer. For example:
=20
=20
class whatever
{
// ...
=20
public:
// ...
=20
int something() const;
};
=20
=20
class your_class: public whatever
{
// ...
=20
public:
//...
=20
// You happen to define something() and
// you did not know it existed(!?)
void something() const;
};
=20
=20
whatever *p=3Dnew your_class;
=20
=20
//whatever::something() is called
// and not your definition
p->something();
=20
=20
=20
Ioannis Vranos
* Programming pages: http://www.noicys.freeurl.com
<http://www.noicys.freeurl.com/>=20
* Alternative URL 1: http://run.to/noicys
* Alternative URL 2: http://www.noicys.cjb.net =
<http://www.noicys.cjb.net/>
|