Re: using vector to encapulate a tree - non const copy constructors
terry wrote:
Repost as the original (13th Oct) did not appear on the site.
Hi, I have a problem with the way some implimentations of vector and other
stl containers refuse to use non-const contructors. My question is - is
the way they function the correct interpretation of the standard - and
if so
why.
MOTIVATION
The following data structure
class mytree: public T, protected std::vector<mytree>{};
defines a tree with an object of type T at each node (it is in top down
form where at each node, one has a value of type T, and a container of
offspring
trees).
As Ulrich pointed out, mytree is not yet anything, and there can be no
containment of something that is a nothing.
The conceptual image you have in mind, trying to make a tree by
successively "spreading" out from a node, is erroneous. You're going to
have to make a full-blow tree structure "in the raw", using internal
linkage, and encapsulate all of it in a class called "mytree".
-Le Chaud Lapin-
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]