Emanuel Ziegler <[EMAIL PROTECTED]> writes:
> compiled without any problems before, it now gives the errors
> error: 'get_test' is neither function nor member function; cannot be
> declared friend
well, the diagnostic is clear; g++ needs a prototype in scope of the
function to be declared friend. the followign compiles correctly:
,-----
| template <class T> class FriendClass;
|
| template <class T> T get_test (const FriendClass<T> &fc) {
| return fc.test; }
|
| template <class T> class FriendClass {
| friend T get_test<T> (const FriendClass<T> &);
| protected:
| T test;
| };
|
| int main () {
| FriendClass<int> fc;
| get_test(fc);
| return 0;
| }
`-----
for your second problem, have a look to the point 2 of the "C++
templates FAQ" at http://womble.decadentplace.org.uk/c++/template-faq.html
--
Maurizio Loreti http://www.pd.infn.it/~loreti/mlo.html
Dept. of Physics, Univ. of Padova, Italy ROT13: [EMAIL PROTECTED]
_______________________________________________
Help-gplusplus mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-gplusplus