Re: [C++] Templates and inheritance
From: Alwyn (dt015a1979_at_mac.com.invalid)
Date: 09/28/04
- Next message: Pedro Graca: "Re: [C++] Templates and inheritance"
- Previous message: Pedro Graca: "Re: [C++] Templates and inheritance"
- In reply to: Pedro Graca: "Re: [C++] Templates and inheritance"
- Next in thread: Pedro Graca: "Re: [C++] Templates and inheritance"
- Reply: Pedro Graca: "Re: [C++] Templates and inheritance"
- Reply: Paul: "Re: [C++] Templates and inheritance"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 28 Sep 2004 22:58:59 +0100
In article <slrncljmco.usv.hexkid@ID-203069.user.uni-berlin.de>, Pedro
Graca <hexkid@hotpop.com> wrote:
> Alwyn wrote:
> > In article <slrncliuer.usv.hexkid@ID-203069.user.uni-berlin.de>, Pedro
> > Graca <hexkid@hotpop.com> wrote:
>
> ========
> I'm now trying to make a
>
> InheritedStack<foo> bar; // :-)
>
> where foo is a class of my own ...
>
> I'm getting a lot of errors, especially with
> operator overloading (for > and <<), but I will
> wait a week or so for my books before showing
> my newbieness :-)
On the whole, it is not a good idea to inherit from STL classes. They
are not designed for that. I would rather write:
template <class T>
class Stack
{
std::stack<T> theStack;
public:
bool empty() const {
return theStack.empty();
}
size_t size() const {
return theStack.size();
}
void push(const T &);
// etc etc.
};
although it is a pain, I admit.
As far as the operators '<' and '<<' are concerned, have you defined
them for your class? You may need to do this.
Alwyn
- Next message: Pedro Graca: "Re: [C++] Templates and inheritance"
- Previous message: Pedro Graca: "Re: [C++] Templates and inheritance"
- In reply to: Pedro Graca: "Re: [C++] Templates and inheritance"
- Next in thread: Pedro Graca: "Re: [C++] Templates and inheritance"
- Reply: Pedro Graca: "Re: [C++] Templates and inheritance"
- Reply: Paul: "Re: [C++] Templates and inheritance"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|