From: Kenshin on 14 Dec 2009 22:36 I am attemting to compile the code below, using MinGW on windows, as below: g++ -std=c++0x -Wall -Os -o varTest varTest.cpp I receive the following compilation error: In file included from d:\apps\qt\2009.05\mingw\bin\../lib/gcc/ mingw32/4.4.0/incude/c++/bits/postypes.h:42, from d:\apps\qt\2009.05\mingw\bin\../lib/gcc/mingw32/4.4.0/incude/c++/ iosfwd:42, from d:\apps\qt\2009.05\mingw\bin\../lib/gcc/mingw32/4.4.0/incude/c++/ ios:39, from d:\apps\qt\2009.05\mingw\bin\../lib/gcc/mingw32/4.4.0/incude/c++/ ostream:40, from d:\apps\qt\2009.05\mingw\bin\../lib/gcc/mingw32/4.4.0/incude/c++/ iostream:40, from varTest.cpp:1: d:\apps\qt\2009.05\mingw\bin\../lib/gcc/mingw32/4.4.0/include/c++/ cwchar:159: eror: '::swprintf' has not been declared d:\apps\qt\2009.05\mingw\bin\../lib/gcc/mingw32/4.4.0/include/c++/ cwchar:166: eror: '::vswprintf' has not been declared varTest.cpp: In function 'int main(int, char**)': varTest.cpp:73: error: no matching function for call to 'sum(int, int, int, int int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int int, int)' varTest.cpp:74: error: no matching function for call to 'minus(int, int, int, it, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, it, int, int)' varTest.cpp:75: error: no matching function for call to 'min(int, int, int, int int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int int, int)' varTest.cpp:76: error: no matching function for call to 'max(int, int, int, int int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int int, int)' varTest.cpp:77: error: no matching function for call to 'avg(int, int, int, int int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int int, int)' I am more concerned about the potion below: varTest.cpp: In function 'int main(int, char**)': varTest.cpp:73: error: no matching function for call to 'sum(int, int, int, int int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int int, int)' varTest.cpp:74: error: no matching function for call to 'minus(int, int, int, it, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, it, int, int)' varTest.cpp:75: error: no matching function for call to 'min(int, int, int, int int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int int, int)' varTest.cpp:76: error: no matching function for call to 'max(int, int, int, int int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int int, int)' varTest.cpp:77: error: no matching function for call to 'avg(int, int, int, int int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int int, int)' Why am I getting this error? (Source code is below). #include <iostream> namespace kgm{ template<class T1, class T2> auto sum(const T1& t1, const T2& t2)->decltype(t1+t2){ return (t1+t2); } template<class T1, class T2, class...T3> auto sum(const T1& t1, const T2& t2, const T3&... t3)->decltype(t1 + sum(t2, t3...)){ return (t1 + sum(t2, t3...)); } template<class T1, class T2> auto minus(const T1& t1, const T2& t2)->decltype(t1-t2){ return (t1-t2); } template<class T1, class T2, class...T3> auto minus(const T1& t1, const T2& t2, const T3&... t3)->decltype(t1 - minus(t2, t3...)){ return (t1 - minus(t2, t3...)); } template<class T1, class T2> auto min(const T1& t1, const T2& t2)->decltype((t1 < t2) ? t1 : t2){ return ((t1 < t2) ? t1 : t2); } template<class T1, class T2, class...T3> auto min(const T1& t1, const T2& t2, const T3&... t3)->decltype(min (((t1 < t2) ? t1 : t2), t3...)){ return min(((t1 < t2) ? t1 : t2), t3...); } template<class T1, class T2> auto max(const T1& t1, const T2& t2)->decltype((t2 < t1) ? t1 : t2){ return ((t2 < t1) ? t1 : t2); } template<class T1, class T2, class...T3> auto max(const T1& t1, const T2& t2, const T3&... t3)->decltype(max (((t2 < t1) ? t1 : t2), t3...)){ return max(((t2 < t1) ? t1 : t2), t3...); } template<class T1, class T2, class...T3> auto avg(const T1& t1, const T2& t2, const T3&... t3)->decltype(sum (t1, t2, t3...)/(2 + sizeof...(T3))){ return (sum(t1, t2, t3...)/(2 + sizeof...(T3))); } }//end namespace kgm// int main(int argc, char** argv){ std::cout << "\nSum:\t" << kgm::sum (1,2,3,4,5,6,7,8,9,11,22,33,44,55,66,77,88,99,0,2243,675,91) << std::endl; std::cout << "\nMinus:\t" << kgm::minus (1,2,3,4,5,6,7,8,9,11,22,33,44,55,66,77,88,99,0,2243,675,91) << std::endl; std::cout << "\nMin:\t" << kgm::min (1,2,3,4,5,6,7,8,9,11,22,33,44,55,66,77,88,99,0,2243,675,91) << std::endl; std::cout << "\nMax:\t" << kgm::max (1,2,3,4,5,6,7,8,9,11,22,33,44,55,66,77,88,99,0,2243,675,91) << std::endl; std::cout << "\nAvg:\t" << kgm::avg (1,2,3,4,5,6,7,8,9,11,22,33,44,55,66,77,88,99,0,2243,675,91) << std::endl; std::cout << std::endl; }//end main// -- [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ]
|
Pages: 1 Prev: Can name be reused in different block? Next: Temporary used for parameter |