[Dev-C++] Can "class templates" be handled by Version 4.9.9.1 ?
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Gabor K. <kal...@ms...> - 2005-02-22 22:42:11
|
<html><div style='background-color:'><DIV class=RTE> <P><FONT size=2><STRONG><U>Can "class templates" be handled by Version 4.9.9.1 ?</U></STRONG></P> <P>I am testing a sample from: <A href="http://www.cplusplus.com/doc/tutorial/tut5-1.html">http://www.cplusplus.com/doc/tutorial/tut5-1.html</A></P> <P><STRONG><U>Here is the source code:</U></STRONG></P> <P>// class templates<BR>#include <iostream><BR>using namespace std;<BR>//=====================================<BR>template <class T><BR>class pair <BR>{<BR> T value1, value2;<BR> public:<BR> pair<T> (T first, T second) {value1=first; value2=second;}<BR> T getmax ();<BR>};<BR>//=====================================</P> <P>template <class T><BR>pair<T>::getmax ()<BR>{<BR> T retval;<BR> retval = value1>value2? value1 : value2;<BR> return retval;<BR>}</P> <P>//=====================================<BR>int main () <BR>{<BR> pair<int> myobject(100, 75);<BR> cout << myobject.getmax();<BR> system("pause");<BR> return 0;<BR>}</P> <P><STRONG><U>Here are the Messages:</U></STRONG></P> <P>Compiler: Default compiler</P> <P>Executing g++.exe...</P> <P>g++.exe "C:\Programming\DEV_CPP\CPP_Tutorial\5_00_Templates\class_template.cpp" -o "C:\Programming\DEV_CPP\CPP_Tutorial\5_00_Templates\class_template.exe" -I"C:\Dev-Cpp\include\c++\3.3.1" -I"C:\Dev-Cpp\include\c++\3.3.1\mingw32" -I"C:\Dev-Cpp\include\c++\3.3.1\backward" -I"C:\Dev-Cpp\lib\gcc-lib\mingw32\3.3.1\include" -I"C:\Dev-Cpp\include" -L"C:\Dev-Cpp\lib" </P> <P>C:\Programming\DEV_CPP\CPP_Tutorial\5_00_Templates\class_template.cpp: In function `int main()':</P> <P>C:\Programming\DEV_CPP\CPP_Tutorial\5_00_Templates\class_template.cpp:26: error: `pair' undeclared (first use this function)</P> <P>C:\Programming\DEV_CPP\CPP_Tutorial\5_00_Templates\class_template.cpp:26: error: (Each undeclared identifier is reported only once for each function it appears in.)</P> <P>C:\Programming\DEV_CPP\CPP_Tutorial\5_00_Templates\class_template.cpp:26: error: expected primary-expression before "int"</P> <P>C:\Programming\DEV_CPP\CPP_Tutorial\5_00_Templates\class_template.cpp:26: error: expected `;' before "int"</P> <P>Execution terminated</P> <P></FONT><BR><BR></P></DIV></div></html> |