Title: | C++ |
Notice: | Read 1.* and use keywords (e.g. SHOW KEY/FULL KIT_CXX_VAX_VMS) |
Moderator: | DECCXX::AMARTIN |
Created: | Fri Nov 06 1987 |
Last Modified: | Thu Jun 05 1997 |
Last Successful Update: | Fri Jun 06 1997 |
Number of topics: | 3604 |
Total number of notes: | 18242 |
/* When compiled, this program yields the error friend class _iset; // (2) ...............^ %CXX-E-REFENCLOSING, In this declaration, "_iset" has a declaration in an enclosing scope, and this class declaration contains a reference to that declaration. If you delete the lines marked (1) (i.e., make it an ordinary class instead of a template class), it compiles successfully. Also, if you interchange the lines marked (2), it compiles successfully. Explanation, please? -Neil */ template <class Key> // (1) class _iset { public: class iterator { const _iset* set; // (2) friend class _iset; // (2) }; }; void main() { _iset <int> // (1) x; }
T.R | Title | User | Personal Name | Date | Lines |
---|---|---|---|---|---|
3463.1 | SPECXN::DERAMO | Dan D'Eramo | Mon Feb 24 1997 20:33 | 12 | |
It will probably work if you change friend class _iset; to friend class _iset<Key>; Don't know whether the latest draft of the standard-to-be requires the <Key> to be there. Dan | |||||
3463.2 | I think it's a bug... | DECC::J_WARD | Tue Feb 25 1997 12:03 | 8 | |
Section 14.6.1 of the standard: "Within the scope of a class template, the name of the template, when not followed by <, is equivalent to the name of the template followed by the template-parameters enclosed in <>. | |||||
3463.3 | a related problem: %CXX-E-INACCESSIBLE | MOIRA::FAIMAN | Tue Feb 25 1997 17:30 | 33 | |
/* In .0, I stated that interchanging the two lines marked (2) allowed the test program to compile successfully. It appears from the following that it was only partially successful. I have interchanged those two lines, but added code in the _iset class which invokes the private constructor of the iterator class. _iset ought to be a friend of iterator now; but compiling this program yields void foo(float k) {iterator i(k);} .................................^ %CXX-E-INACCESSIBLE, In this declaration, "_iset<int >::iterator::iterator" is not accessible. As before, removing the lines marked (1) (i.e., making _iset an ordinary class rather than a template class) eliminates the problem. */ template <class Key> // (1) class _iset { public: class iterator { friend class _iset; // (2) const _iset* set; // (2) iterator(float); }; void foo(float k) {iterator i(k);} }; void main() { _iset <int> // (1) x; } | |||||
3463.4 | MOIRA::FAIMAN | Tue Feb 25 1997 17:36 | 6 | ||
The problem reports in .0 and .3 were based on DEC C++ V5.4 on VAX/VMS. I just confirmed that the problem in .0 occurs with V5.5 on Alpha/VMS and on Alpha/Unix. Oddly enough, the problem in .3 occurs with V5.5 on Alpha/Unix, but *not* with V5.5 on Alpha/VMS. -Neil |