The Daily Static
  The Daily Static
UF Archives
Register
UF Membership
Ad Free Site
Postcards
Community

Geekfinder
UFie Gear
Advertise on UF

Forum Rules
& FAQ


Username

Password


Create a New Account

 
 

Back to UserFriendly Strip Comments Index

Attn: C++ gurus by nix2003-10-22 13:35:28
  How was blech declared? by ToLazyToThink2003-10-22 14:35:26
    here's some exact code that has the same issue by nix 2003-10-22 15:56:53
#include <iostream>
#include <typeinfo>
using namespace std;

template <class TYPE>
class blah
{
    TYPE feh;
    public:
    void blech(int x);
    template <class T> void gak(int x);
    template <class T> void eck(int x);
    void ugh(int x);
};

template <class TYPE> template <class T> void blah<TYPE>::gak(int x)
{
    T a;
    cout << typeid(a).name() << endl;
}

template <> template <class T> void blah<int>::eck(int x)
{
    T a;
    cout << typeid(a).name() << endl;
}

template <class TYPE> void blah<TYPE>::blech(int x)
{
    cout << typeid(feh).name() << endl;
}

template <> void blah<int>::ugh(int x)
{
    cout << typeid(feh).name() << endl;
}


template <class T>
void foobar(int x)
{
  T a;
  cout << typeid(a).name() << endl;
}

int main()
{

  return 0;
}

This compiles and works properly when I comment out the declaration and definition of the method 'eck'. With "eck" in there, g++ fails with
ttest.cpp:23: template-id `eck<>' for `void blah<int>::eck(int)' 
does not match any template declaration
ttest.cpp:23: syntax error before `{' token
ttest.cpp:25: syntax error before `<<' token

Note that 'gak' (a template function in a template class) works, as does 'ugh" (a normal function in a specialized template class); it's only 'eck', a template function in a specialized template class, that fails
[ Reply ]
      BTW, the compiler was GCC 3.2.2 20030222 by nix2003-10-22 16:16:37
      Ok, I think I got it by sereth2003-10-22 17:29:03

 

[Todays Cartoon Discussion] [News Index]

Come get yer ARS (Account Registration System) Source Code here!
All images, characters, content and text are copyrighted and trademarks of J.D. Frazer except where other ownership applies. Don't do bad things, we have lawyers.
UserFriendly.Org and its operators are not liable for comments or content posted by its visitors, and will cheerfully assist the lawful authorities in hunting down script-kiddies, spammers and other net scum. And if you're really bad, we'll call your mom. (We're not kidding, we've done it before.)