Partilhar via


Implicitly Abstract Classes

If a class has interface base type, and if the class does not implement all the interface's member functions, then the class is implicitly abstract, and you cannot instantiate the class.

For more information about abstract classes, see abstract.

// mcppv2_ref_class5.cpp
// compile with: /clr
interface struct MyInterface {
   void func1();
   void func2();
};

ref class MyClass : public MyInterface {
public:
   void func1(){}
   // void func2(){}
};

int main() {
   MyClass ^ h_MyClass = gcnew MyClass;   // C2259 
                        // uncomment MyClass::func2 to resolve
}

See Also

Reference

Classes and Structs (Managed)