Calling a base class' method

前端 未结 3 1414
抹茶落季
抹茶落季 2020-12-05 12:39

In c++ I would do

class A
{
public:
    virtual void stuff()
    {
        //something
    }
};

class B : public A
public:
    virtual void stuff()
    {
           


        
相关标签:
3条回答
  • 2020-12-05 13:04

    Use base. Like base.stuff();

    0 讨论(0)
  • 2020-12-05 13:15

    base is the keyword for referencing your superclass in C#. Use:

    base.stuff();
    
    0 讨论(0)
  • 2020-12-05 13:22

    Just to add to the answer above, base.stuff() works, unless it's the constructor you're trying to call in which case it is called as:

    class A
    {
    public:
        public A(){}
    
    };
    
    class B : A
    {
        public B() : base()
        {
    
        }
    };
    
    0 讨论(0)
提交回复
热议问题