乱七八糟的片段

原创
2012/06/20 15:44
阅读数 68
#include <iostream>

using namespace std;

class Unkown
{
public:
	void QueryInterface(int a)
	{
		cout<<"Hello, this your world!" <<endl;
	}
};

template <typename T> class Helper
{
public:
	T *t;

public:
	T *operator -> ()
	{
		cout<<"your world!" <<endl;
		return t;
	}
};

int main(int argc, char *argv[])
{
	Helper<Unkown> tt;
	tt->QueryInterface(10);

	return 0;
}
//函数模板
#include <iostream>

using namespace std;

template <typename T>

inline const T &Maximnum(const T &x, const T &y)
{
	if (y > x)
	{
		return y;
	}
	else
	{
		return x;
	}
}

int main(int argc, char *argv[])
{
	cout<<Maximnum<int>(3, 7) <<endl;
	cout<<Maximnum(3, 7) <<endl;
	cout<<Maximnum<double>(3.0, 7.0) <<endl;

	return 0;
}


展开阅读全文
加载中
点击引领话题📣 发布并加入讨论🔥
0 评论
0 收藏
0
分享
返回顶部
顶部