团购网站开发需要多久,网站技能培训,低代码平台设计,0元购怎么在网站做需要注意的是#xff0c;模板中函数或方法#xff0c;要在类或头文件中实现。关键字typename 和class基本等同。构造类模板时#xff0c;要指明模板参数类型#xff0c;而函数模板则不用指明参数类型。 #pragma once#include string.h#include windows.hus…需要注意的是模板中函数或方法要在类或头文件中实现。关键字typename 和class基本等同。构造类模板时要指明模板参数类型而函数模板则不用指明参数类型。 #pragma once#include string.h#include windows.husing namespace std;template typename T
T compare(T t1, T t2) {if (t1 t2) {return t1;}else {return t2;}
};template typename T
class TEST {public:T m_t;TEST() {};virtual ~TEST() {};T compare(T t1, T t2) {return t1 t2;};int comparestr(T t1 string, T t2 string) {string s1 t1;string s2 t2;char * buf1 (char*)s1.c_str();char * buf2 (char*)s2.c_str();return (buf1[0] buf2[0]);};
};
#include windows.h#include string
#include stdio.h
#include main.husing namespace std;int main() {try {double resd 0;int res 0;const char * resc 0;resd compare(7.01, 7.1);res compare(6, 5);resc compare(hello, world);TESTchar* test;TESTdouble testd;int result 0;double resultd testd.compare(6.6789, 7.01);resultd testd.compare(6.6789, 6.7);result test.comparestr(testo,hello);throw(hello world!\r\n); }catch (char * ex) {try {printf(throw string:%s\r\n, ex);throw(12345678);}catch (int e) {printf(throw number:%d\r\n, e);//exit(0);}}return 0;}