Topic: Inherit/templates/func ptr Error??


Author: fll@h4gate.ssw.melpar.esys.com (Fred LaBar)
Date: 20 Feb 95 15:29:45 GMT
Raw View
Fred LaBar (fll@h4gate.ssw.melpar.esys.com) wrote:
: Should the following compile???
: --------------------------

: template<class T>
: struct CC
: {
:     T temp;
:     CC( void (*func)(const T&)) { func(temp); }
: };

: struct Base {};

: struct Der : public Base  {};

: void func(const Base& t) // if this param is of type Der it
:                          // will compile fine... why???
: {}

: int main()
: {
:     CC< Der > d(func);
:     return 1;
: }

I posted this to comp.lang.c++ and am not getting any responses...
Maybe comp.std.c++ should be answering my question???

The main problem is that my compiler is not using a function pointer
as expected. (according to base pointers and derived obects...)

This was done with g++ and sgi's Delta C++ compiler(DCC)

I am hesitant to make a fuss over it because I am not sure that it
should compile... :)

------

Frederick LaBar
(703) 560-5000 x2017
flabar@melpar.esys.com
fredster@flabar.us.net