Java 不支持抽象类的多重继承,但我试图在 C++ 中做与此等效的操作:
//this is Java-style pseudocode
public abstract class Rectangle{
public abstract double getHeight();
public abstract double getWidth();
public double getHeight(){
return getWidth()*getHeight();
}
}
public abstract class Container{
public abstract void printTypes();
public abstract void printEachElement();
public void printContainerStuff(){
System.out.print("Has the types: ");
printTypes();
System.out.print("List of elements: ");
printEachElement();
}
}
public abstract class Array extends Rectangle, Container{ //this can't be done in Java, but what about C++?
}
C++ 中是否有等效的 Java 抽象类可以做到这一点?