The code at the end of this message works just fine with M$ VS2005 but with g++ 4.1.3 i get this:
node.cpp: In function ‘int main()’: node.cpp:96: error: no matching function for call to ‘bnode<cxsc::interval>::bnode(cxsc::interval*, cxsc::interval*, <unresolved overloaded function type>)’ node.cpp:38: note: candidates are: bnode<T>::bnode(const T*, const T*, T (*)(const T&, const T&)) [with T = cxsc::interval] node.cpp:34: note: bnode<T>::bnode() [with T = cxsc::interval] node.cpp:30: note: bnode<cxsc::interval>::bnode(const bnode<cxsc::interval>&) node.cpp:100: error: no matching function for call to ‘bnode<cxsc::interval>::bnode(cxsc::interval*, cxsc::interval*, <unresolved overloaded function type>)’ node.cpp:38: note: candidates are: bnode<T>::bnode(const T*, const T*, T (*)(const T&, const T&)) [with T = cxsc::interval] node.cpp:34: note: bnode<T>::bnode() [with T = cxsc::interval] node.cpp:30: note: bnode<cxsc::interval>::bnode(const bnode<cxsc::interval>&) The crazy thing is that this node<interval>* presult = new unode<interval> (&x, exp); interval r = presult->evaluate(); works with g++ 4.1.3 correctly. The class interval is from C-XSC here: http://xsc.de . Any help is appreciated. ------------------------------------------------------------------------- [node.cpp] #include "interval.hpp" #include "imath.hpp" using namespace cxsc; #ifdef _MSC_VER #define _CRTDBG_MAP_ALLOC #include <stdlib.h> #include <crtdbg.h> #ifdef _DEBUG #define new new( _NORMAL_BLOCK, __FILE__, __LINE__) #else #define DEBUG_NEW #endif #endif template <class T> class node { public: virtual const T evaluate() = 0; virtual ~node(); }; template <class T> node<T>::~node() {} template <class T> class bnode : public node<T> { public: bnode<T> () : node<T> () {}; bnode<T> (const T* const Arg1, const T* const Arg2, T Bop (const T&, const T&)) : node<T> (), arg1(Arg1), arg2(Arg2), bop(Bop) { }; virtual const T evaluate(); ~bnode<T>() {} ; private: const T* arg1; const T* arg2; T (*bop) (const T&, const T&); }; template <class T> const T bnode<T>::evaluate() { return (bop(*arg1, *arg2)); } template <class T> class unode : public node<T> { public: unode<T> () : node<T> () {}; unode<T> (const T* const Arg, T Uop (const T& ) ) : node<T> (), arg(Arg), uop(Uop) { }; virtual const T evaluate(); ~unode<T>() {} ; private: const T* arg; T (*uop) (const T& ); }; template <class T> const T unode<T>::evaluate() { return (uop(*arg)); } int main() { // exp(x + y*z) interval x(2), y(3), z(0.5); node<interval>* pyz = new bnode<interval> (&y, &z, operator*); interval yz = pyz->evaluate(); node<interval>* px_p_yz = new bnode<interval> (&x, &yz, operator+); interval x_p_yz = px_p_yz->evaluate(); node<interval>* presult = new unode<interval> (&x_p_yz, exp); interval r = presult->evaluate(); delete pyz; delete px_p_yz; delete presult; #ifdef _MSC_VER _CrtDumpMemoryLeaks(); #endif return 0; } _______________________________________________ help-gplusplus mailing list help-gplusplus@gnu.org http://lists.gnu.org/mailman/listinfo/help-gplusplus