main.cpp

来自「C++ Source code from a tutorial」· C++ 代码 · 共 29 行

CPP
29
字号
#include <iostream>
#include <stdlib.h>
#include <string>

using namespace std;

template <class MyType, int Size> class Templatable {
public:
    MyType value[Size];
};

int main(int argc, char *argv[])
{
    Templatable<int,3> inst;
    inst.value[0] = 10;
    inst.value[1] = 20;
    inst.value[2] = 30;
    cout << inst.value[2] << endl;
    
    typedef Templatable<string,2> DualString;
    DualString inst2;
    inst2.value[0] = "abc";
    inst2.value[1] = "def";
    cout << inst2.value[1] << endl;
    
    system("PAUSE");	
    return 0;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?