Java不支持多重继承抽象类的抽象类,但我试图做的在C++中等价的:多重继承在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++?
}
有Java的抽象类的等效在C++中可以做到这一点?
对不起,我在编辑你的答案之前注意到hmjd已经提供了你的信息。我回滚了,我不知道这是不是该做的事情... –
在C++中执行纯虚函数就像Java中的抽象方法一样吗? –
@安德森·格林:是的。 – Nawaz