the C++ have virtual functions, but, for me they have 1 problem: on derived class, i must prototype them, for define them on Global Scope.
how can i avoid the re-prototype them on derived class?
i tried 1 way:

template <class Type>
class TypeHasToString
    // This type won't compile if the second template parameter isn't of type T,
    // so I can put a function pointer type in the first parameter and the function
    // itself in the second thus checking that the function has a specific signature.
    template <typename T, T> struct TypeCheck;
    typedef char Yes;
    typedef long No;

    // A helper struct to hold the declaration of the function pointer.
    // Change it if the function signature changes.
    template <typename T> struct ToString
        typedef void (T::*fptr)();

    template <typename T> static Yes HasToString(TypeCheck< typename ToString<T>::fptr, &T::MouseClick >*); //function name
    template <typename T> static No  HasToString(...);

    static bool const value = (sizeof(HasToString<Type>(0)) == sizeof(Yes));

template <typename CBase>
class test
    CBase* atPointer = nullptr;

    void MouseClick(){;};
    test(CBase *clsPointer) : atPointer(clsPointer)
        //use it:
        std::cout << TypeHasToString<CBase>::value;

    void call()

//ClassWithEvents(test,FormEvents, b);

class InstanceName : public test<InstanceName>
{ // manual expansion of ClassWithEvents
    InstanceName() : test(this){;}


    void MouseClick();
//  void Move();                       // error 1
} InstanceName;

// void b::MouseClick()                    // possible error 2
void InstanceName::MouseClick()
    std::cout << "Mouse click";

these template is for test if the class test::CBase have the MouseClick().
these code works, but it's limited: if we have the function prototype(but not defined), i will get '1' instead zero.
so what you can advice me more?

Edited by cambalinho

2 Weeks
Discussion Span
Last Post by cambalinho

Moderator: i'm sorry, but i can't add the code on same textbox code.. isn't my error :(
edit: i fixed, just for delete the '-' after ':', after new line.. i don't know why

Edited by cambalinho

Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.