Re: containing one's own type
On Jul 24, 10:16 pm, Dar=EDo Griffo <dario.griffo.lis...@gmail.com>
wrote:
On Jul 24, 5:02 pm, James Kanze <james.ka...@gmail.com> wrote:
On Jul 24, 9:45 pm, Dar=EDo Griffo <dario.griffo.lis...@gmail.com>
wrote:
On Jul 24, 2:56 pm, Christopher <cp...@austin.rr.com> wrote:
Related to my last post, but seperate question
Can a class be made into a container of its self?
Of course
#include <vector>
class Test {
int i;
std::vector<Test> myselfVector;
};
Which is undefined behavior,
I didn't know that.
Where can I find more information? Any paper?
The standard. More generally, however, any textbook concerning
the STL should point out that you're only allowed to instantiate
it for complete types (which is, in fact, true of every template
currently in the standard).
and won't compile with g++.
dario@illusion:~/test$ g++ test.cpp -o showmethemoney
dario@illusion:~/test$ ls -lh
-rwxr-xr-x 1 dario dario 8.6K 2008-07-24 17:12 showmethemoney
-rw-r--r-- 1 dario dario 135 2008-07-24 17:12 test.cpp
dario@illusion:~/test$ g++ --version
g++ (Debian 4.3.1-2) 4.3.1
By default, g++ (like all other compilers I know) doesn't
implement C++, but rather a somewhat similar, but not identical,
language. For everyday use, I use "g++ -std=c++98 -pedantic
-ffor-scope -fno-gnu-keywords -foperator-names -pipe -Wall -W
-Woverloaded-virtual -Wno-sign-compare -Wno-deprecated
-Wno-non-virtual-dtor -Wpointer-arith -Wno-unused -Wno-switch
-Wno-missing-braces -Wno-long-long -static-libgcc -ggdb3
-D_GLIBCXX_CONCEPT_CHECKS -D_GLIBCXX_DEBUG
-D_GLIBCXX_DEBUG_PEDANTIC". (Some of the options represent
personal preferences, of course, and some correspond to
constraints due to the code I work with -- -Wno-long-long, for
example. But as a very minimum, if you're trying to work in
standard C++, you need -std=c++98 -pedantic
-D_GLIBCXX_CONCEPT_CHECKS -D_GLIBCXX_DEBUG
-D_GLIBCXX_DEBUG_PEDANTIC, and perhaps -ffor-scope
-fno-gnu-keywords.)
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34