home *** CD-ROM | disk | FTP | other *** search
- From: kevinc@hpcc01.corp.hp.com (Kevin Collins)
- Date: Thu, 5 Nov 1992 18:04:18 GMT
- Subject: Inheritance & operator overloading
- Message-ID: <1000009@hpcc01.corp.hp.com>
- Organization: the HP Corporate notes server
- Path: sparky!uunet!charon.amdahl.com!pacbell.com!decwrl!sun-barr!ames!saimiri.primate.wisc.edu!zaphod.mps.ohio-state.edu!sdd.hp.com!scd.hp.com!hpscdm!hplextra!hpcc05!hpcc01!kevinc
- Newsgroups: comp.lang.c++
- Lines: 42
-
-
- I have a child of an array class that inherits an overloaded operator=.
- I need to add some functionality to that operator= then I would like to
- call the *inherited* operator=. What is the syntax for this? I've
- done it many times for "normal" functions ...
-
- Thanks,
-
- Kevin
- -----------------------------------------------
-
- template <class Type>
- class baseArray {
-
- public :
-
- Type& operator[] (int i);
-
- }
-
- template <class Type>
- class child : public Block<Type> {
-
- public :
-
- Type& operator[] (int i);
-
- }
-
-
- template <class Type>
- Type& child<Type>::operator[] (int i) {
-
- // do something of added value here ...
-
- return a call of inherited operator[] call here, meaning something like :
- ---------
-
- return (*this)[i]; // but NOT this since this will create an infinite loop.
-
- }
-
-