home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!mcsun!julienas!loria!loria.fr!eker
- From: eker@loria.fr (Steven Eker)
- Newsgroups: comp.lang.c++
- Subject: classes within templates
- Message-ID: <691@muller.loria.fr>
- Date: 14 Dec 92 12:08:42 GMT
- Sender: news@news.loria.fr
- Organization: CRIN (CNRS) Nancy - INRIA Lorraine
- Lines: 39
-
- What is the semantics of nesting classes within a template class?
- I want to implement a template container class where the internal structs are
- hidden:
-
- template<class T> class My_container {
-
- struct internal_stuff {
- internal_stuff* link;
- T data;
- ...
- };
-
- internal_stuff* ptr1;
- ...
- };
-
- This seems to work ok until I want to have an friend class for iterators
- (assume "friend class My_iter<T>;" included in above def):
-
- template<class T> class My_iter {
-
- internal_stuff* ptr2;
- ...
- };
-
- At this point the compiler (gcc v2.1) complains of a syntax error
- before '*' and bombs.
-
- What is the status of "internal_stuff"? Is it implicitly parameterised
- by T? Does it make sense to declare a template within a template
- (a) with parameters that are a subset of enclosing templete parameters
- (b) with parameters that don't exist in enclosing template?
-
- What's the best way to hide the internal classes/structs of a complicated
- container class from global name space?
-
- tia
-
- Steven eker@loria.fr
-