Is there an alternative in C++/CLI for C# "base"

Hi,

when you override functions of a derived class you often have to call the corresponding base class function.

In C# you could write:

base.OnClick(args); // to call the bass class' OnClick function

In C++/CLI I always write i.e.:

Button::OnClick(args);

or

xyz::abc::deg::OnClick(args);

Is there something similar to C#'s base, so you don't have to repeat the whole base class namespace::classname stuff.

Thank you,
wannabe



Answer this question

Is there an alternative in C++/CLI for C# "base"

  • shayc

    You could use __super

    namespace Nish
    {
    ref class Base
    {
    public:
    void A()
    {
    }
    };

    ref class Derived : Base
    {
    public:
    void A()
    {
    __super::A();
    }
    };
    }

    wannabe_2 wrote:

    Hi,

    when you override functions of a derived class you often have to call the corresponding base class function.

    In C# you could write:

    base.OnClick(args); // to call the bass class' OnClick function

    In C++/CLI I always write i.e.:

    Button::OnClick(args);

    or

    xyz::abc::deg::OnClick(args);

    Is there something similar to C#'s base, so you don't have to repeat the whole base class namespace::classname stuff.

    Thank you,
    wannabe



  • deebeez

    use __super:: for C++
  • Is there an alternative in C++/CLI for C# "base"