A member template cannot be virtual. For example:
class Shape {
//...
template virtual bool intersect(const T&) const = 0; // error: virtual template
};
This must be illegal. If it were allowed, the traditional virtual function table technique for implementing virtual function could not be used. The linker would have to add a new entry to the virtual table for class Shape each time someone called intersect() with a new argument type.
- The C++ Programming Language 3rd Edition (Stroustrap)
class Shape {
//...
template
};
This must be illegal. If it were allowed, the traditional virtual function table technique for implementing virtual function could not be used. The linker would have to add a new entry to the virtual table for class Shape each time someone called intersect() with a new argument type.
- The C++ Programming Language 3rd Edition (Stroustrap)
'Dev > C++' 카테고리의 다른 글
A non-type template-parameter (0) | 2007.05.14 |
---|---|
Member template specialization (0) | 2007.05.14 |
sgi STL - Why does Bounds Checker™ say that I have memory leaks? (0) | 2007.05.14 |
MinGW - Why is my C++ binary so large? (0) | 2007.05.14 |
Why doesn't C++ provide a "finally" construct? (0) | 2007.05.14 |