N
Nemanja Trifunovic
Something I don't get it:
Say we have:
ref class Base {
virtual void SomeVirtualFunction()
{Console::WriteLine(L"Base");}
public:
void SomeAccessibleFunction()
{SomeVirtualFunction();}
};
ref class Derived : public Base {
virtual void SomeVirtualFunction()
{Console::WriteLine(L"Derived");}
};
int main(array<System::String ^> ^args)
{
Base^ handle = gcnew Derived();
handle->SomeAccessibleFunction();
return 0;
}
I would expect to get "Derived" as the result, right? However, I get
"Base", and strange warnings during compilation:
".\PrivateVirtual.cpp(8) : warning C4486: 'Base::SomeVirtualFunction' :
a private virtual method of a ref class or value class should be marked
'sealed'
..\PrivateVirtual.cpp(16) : warning C4486:
'Derived::SomeVirtualFunction' : a private virtual method of a ref
class or value class should be marked 'sealed'
"
If I try explicit overriding:
..\PrivateVirtual.cpp(17) : error C3671: 'Derived::SomeVirtualFunction'
: function does not override 'Base::SomeVirtualFunction'
..\PrivateVirtual.cpp(16) : warning C4486:
'Derived::SomeVirtualFunction' : a private virtual method of a ref
class or value class should be marked 'sealed'
What is going on here?
Say we have:
ref class Base {
virtual void SomeVirtualFunction()
{Console::WriteLine(L"Base");}
public:
void SomeAccessibleFunction()
{SomeVirtualFunction();}
};
ref class Derived : public Base {
virtual void SomeVirtualFunction()
{Console::WriteLine(L"Derived");}
};
int main(array<System::String ^> ^args)
{
Base^ handle = gcnew Derived();
handle->SomeAccessibleFunction();
return 0;
}
I would expect to get "Derived" as the result, right? However, I get
"Base", and strange warnings during compilation:
".\PrivateVirtual.cpp(8) : warning C4486: 'Base::SomeVirtualFunction' :
a private virtual method of a ref class or value class should be marked
'sealed'
..\PrivateVirtual.cpp(16) : warning C4486:
'Derived::SomeVirtualFunction' : a private virtual method of a ref
class or value class should be marked 'sealed'
"
If I try explicit overriding:
..\PrivateVirtual.cpp(17) : error C3671: 'Derived::SomeVirtualFunction'
: function does not override 'Base::SomeVirtualFunction'
..\PrivateVirtual.cpp(16) : warning C4486:
'Derived::SomeVirtualFunction' : a private virtual method of a ref
class or value class should be marked 'sealed'
What is going on here?