Topic: Friend template function : Is the compiler right?
Author: Alex Vinokur <alexander.vinokur@telrad.co.il>
Date: 1999/06/16 Raw View
Hi,
Here is a program and my question.
Thanks in advance,
Alex
//#########################################################
//------------------- C++ code : BEGIN -------------------
template <typename T1> class AAA {public : AAA (); };
template <typename T1> void FFF ();
template <typename T1>
class CCC
{
friend class AAA<int>;
friend void FFF<int> ();
private :
CCC (T1 t1) {}
public :
~CCC () {}
};
//--------------------
template <typename T1>
AAA<T1>::AAA ()
{
CCC<T1> (T1 ());
};
//--------------------
template <typename T1>
void FFF ()
{
CCC<T1> (T1 ());
};
int main ()
{
AAA<int> a1;
// AAA<char> a2; Compiler error message :
// `CCC<char>::CCC<char>(char)' is private
// (I think) The compiler is right
FFF<int> ();
FFF<char> (); // There is no error message. Is the compiler
right?
return 0;
}
//------------------- C++ code : END ----------------------
//#########################################################
//------------------- Compiler & System ------------------
g++ -v : gcc version egcs-2.91.57 19980901
(egcs-1.1 release)
uname -a : SunOS <nodename> 5.6 Generic_105181-09
sun4m sparc SUNW,SPARCstation-5
//---------------------------------------------------------
//#########################################################
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
[ Send an empty e-mail to c++-help@netlab.cs.rpi.edu for info ]
[ about comp.lang.c++.moderated. First time posters: do this! ]
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]