何か不足していますか、それとも Visual Studio のバグを見つけましたか?
バグはさておき、このタイプの継承を使用することは問題ないのでしょうか?
GCC 4.9.0 では、期待どおりの結果が得られます。
base.getProperty() 1
otherBase.getProperty() 2
derivedA.getProperty() 1
derivedB.getProperty() 2
ただし、VS 2015 (CTP 6) と VS 2013 (Update 5 CTP) の両方で、間違った結果と思われる結果が生成されます。
base.getProperty() 1
otherBase.getProperty() 2
derivedA.getProperty() 1
derivedB.getProperty() 1
「クラスの派生クラス B : パブリックの派生クラス A、他のベースクラス {」を「クラスの派生クラス B : パブリックの他のベースクラス、派生クラス A {」に変更すると、期待どおりの結果が得られます。何かが欠けている可能性がありますが、継承元のクラスの順序は初期化の順序に影響しますが、使用するあいまいな関数に影響を与えるとは思われません。
#include <iostream>
using namespace std;
class baseClass {
public:
virtual int getProperty() {
return 1;
}
};
class otherBaseClass : public baseClass {
public:
virtual int getProperty() {
return 2;
}
};
class derivedClassA : public baseClass {
public:
void someUniqueThing() {
cout << "someUniqueThing" << endl;
}
};
class derivedClassB : public derivedClassA, otherBaseClass {
public:
using otherBaseClass::getProperty;
};
int main() {
baseClass base;
cout << "base.getProperty() " << base.getProperty() << endl;
otherBaseClass otherBase;
cout << "otherBase.getProperty() " << otherBase.getProperty() << endl;
derivedClassA derivedA;
cout << "derivedA.getProperty() " << derivedA.getProperty() << endl;
derivedClassB derivedB;
cout << "derivedB.getProperty() " << derivedB.getProperty() << endl;
}