Topic: problems with new operator and class-function-pointers
Author: Thomas Lehmann <tlehmann@mail.iez.com>
Date: 1999/07/22 Raw View
Hi,
With the following definitions I got a problem, calling
new: (explanation follows)
---
void* operator new( unsigned int p_iSize )
{
return ( malloc( p_iSize ) ) ;
}
class MyClass
{
public: void test( void ) {/*does nothing*/}
} ;
...
typedef void (MyClass::*MyClassFunctions)(void) ;
...
template <class T>
Anything<T>::setValue( const T& p_Value )
{
T* Value = new T ; // uses overwritten operator new
...
}
...
MyClass MyCl ;
Anything <MyClassFunctions> MyFunc ;
MyFunc.setValue(
(MyClassFunctions)MyCl.test ) ;
---
Now, inside the operator new 'p_iSize' is zero, because it took 'void'
as the type not the function pointer. If I take double as return value I
get
'8' as size. How do I have do define correct the typedef ????
(funny is, the call of that function works well)
-->
MyClassFunction aFunc = *MyFunc.getValue() ;
(MyCl.*aFunc)() ;
bye,
Thomas
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]