ch16_05.cpp

来自「在文件中含有大量基础C program code以公初学者参考」· C++ 代码 · 共 26 行

CPP
26
字号
#include <iostream>
using namespace std;
template <class type>
class function
{
  private:
        type y;
  public:
        function(type x) {y=x;}
        void show()
        {
            cout<<"y="<<y<<endl;
        }
};
int main()
{    
    function<int> func1(10);
    func1.show();
    function<float> func2(9.8);
    func2.show();
    function<char> func3('z');
    func3.show();
    return 0;
}

⌨️ 快捷键说明

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