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 nix2003-10-22 15:56:53
      Ok, I think I got it by sereth 2003-10-22 17:29:03
It seems that g++ is looking for a specialized definition of blah<int> when you try to define blah::eck(). Also with the code above, if you try to declare a variable of type blah<float> and then call ugh, the link dies phase dies with an error because there is no definition for blah<float>::ugh().

The code below will compile correctly, and work in most cases...it still doesn't fix the problem with trying to call blah<anything_but_int>::ugh(). I could be way off base here, but this is the understanding I get from toying with code you posted. Hope it helps.
#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 blah<int>
{
    int 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;
}
[ Reply ]

 

[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.)