0

I was trying to acomplish something similar to Java "super" call which i thought would be possible in this way :

public ref class base {

public: base(){}

protected: virtual void funct()
{
   MessageBox::Show("base funct");
}
};

public ref class derived : public base
{
public: derived() : base(){}

protected: virtual void funct() new
{
((Base^)this)->funct();
///some work
}
};

But it gives me "Candidate function(s) not accesible" error. Doesn't "protected" modifier gives acces to base class elements to all its subclasses? I dont know if it makes any difference but Base class method that i want to override is inherited by Base aswell.

user1079475
  • 379
  • 1
  • 5
  • 17

1 Answers1

1

Your syntax is incorrect, you can call base functions like this.

base::funct();

It complains because, after the cast, you have an instance of base. The funct() function is protected, therefore you can't call it on a given instance of base.

Chris Hannon
  • 4,134
  • 1
  • 21
  • 26