template-id does not match any template declaration

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,
I am a novice for C++, and I compiled a program with C++ and there are an error, Pleaes help me.


Thanks,

#include <iostream>

template <class T>
class pair {
   T value1, value2;
 public:
   pair (T first, T second)
     {value1=first; value2=second;}
   T module () {return 0;}
};

template <>
class pair <int> {
   int value1, value2;
 public:
   pair (int first, int second)
     {value1=first; value2=second;}
   int module ();
};

template <>
int pair<int>::module() {
 return value1%value2;
}
int main () {
 pair <int> myints (100,75);
 pair <float> myfloats (100.0,75.0);
 std::cout << myints.module() << '\n';
 std::cout << myfloats.module() << '\n';
 return 0;
}

Error:
templatemodule1.cpp:22: error: template-id `module<>' for `int
  pair<int>::module()' does not match any template declaration
templatemodule1.cpp:22: error: syntax error before `{' token

_________________________________________________________________
Add photos to your messages with MSN 8. Get 2 months FREE*. http://join.msn.com/?page=features/featuredemail



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux