- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello, the icpc returns on the following code an error: 'error: "a" has already been declared in the current scope ', which is misleading as the error can be solved by declaring the function (like in the two commented lines). The gcc warns me with: 'warning: friend declaration ‘T N::a(C
#include <iostream> template <typename T> class C; namespace N { template <typename T> T a(C<T> b); //template <typename T> //T a(C<T>, int); } // END namespace N template <typename T> class C { T i; public: C(T i = 0) : i(i) { } template <typename T2> friend T N::a(C<T2>); friend T N::a(C, int); }; int main() { C<int> mc(7); } namespace N { template <typename T> T a(C<T> b) { return b.i; } template <typename T> T a(C<T> b, int c) { return b.i+c; } } // END namespace N
Link Copied
0 Replies

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page