C++练习笔记_2

C++练习笔记_2

我在打酱油,Don’t look…

//2010/11/19
//Zephyr
//Template Test

#include <iostream>
using namespace std;
#define  MyWord "陷阱无处不在"  //真的

template <typename my>
void SetVal(my &ori)
{
    ori+=ori;
}
template <typename T1,typename T2>
void MulVal(T1 &ori,T2 count)
{
    ori*=count;
}
template <typename T,typename T2>
class MyTemp
{
private:
    T m_Val;
    T2 m_Val2;
public:
    MyTemp(T val,T2 val2){m_Val=val;m_Val2=val2;}
    T GetVal();
};
template<typename T,typename T2>
T MyTemp<T,T2>::GetVal()
{
    return m_Val;
}
void main()
{
    MyTemp<int,unsigned char> new1(10,128);
    MyTemp<double,string> new2(168.6451,string("What's up?"));
    cout<<new1.GetVal()<<endl;
    cout<<new2.GetVal()<<endl;

    int t1=10;
    double t2=16.6;
    SetVal(t1);
    SetVal(t2);
    cout<<t1<<endl<<t2<<endl;
    MulVal(t2,t1);
    cout<<t2<<endl;
    cout<<MyWord<<endl;
    system("pause");
}
ps:
有了这个LiveWriter,终于可以解脱痛苦的图片问题了~~~
放两个FF的美图,以资鼓励:
MM GG 
 
 
posted @ 2010-11-19 15:16  Zephyroal  阅读(319)  评论(0编辑  收藏  举报