• C++ Template Class


     1 #pragma once
    2
    3 #include "targetver.h"
    4
    5 #include <stdio.h>
    6 #include <tchar.h>
    7
    8 template <class T>
    9 class CThree
    10 {
    11 public:
    12 CThree(T t1,T t2,T t3);
    13 T Min();
    14 T Max();
    15 private:
    16 T a,b ,c;
    17 };

      


     1 #include "stdafx.h"
    2 #include <ostream>
    3 //#include <iostream>
    4 using namespace std;
    5
    6 template <class T>
    7 T CThree<T>::Min()
    8 {
    9 T minab=a<b?a:b;
    10 return minab<c?minab:c;
    11 }
    12 template <class T>
    13 T CThree<T>::Max()
    14 {
    15 T maxab=a<b?b:a;
    16 return maxab<c?c:maxab;
    17 }
    18 template <class T>
    19 CThree<T>::CThree(T t1, T t2, T t3):a(t1),b(t2),c(t3)//?
    20 {
    21 return;
    22 }
    23 int _tmain(int argc, _TCHAR* argv[])
    24 {
    25 CThree<int> obj1(2,5,4);
    26 cout<<obj1.Min()<<endl;
    27 cout<<obj1.Max()<<endl<<std::max(;
    28
    29 CThree<float> obj2(8.52f,-6.75f,4.54f);
    30 cout <<obj2.Max()<<endl;
    31 cout<<obj2.Min()<<endl;
    32
    33 return 0;
    34 }

      

  • 相关阅读:
    MetaNamespaceKeyFunc
    golang dlv 调式成员函数
    golang 编译 添加debug gdb
    code-generator
    k8s 自定义informer
    kube-batch ——pod 和task
    kubernetes-handbook informer
    kube batch scheduler
    k8s-scheduler-extender-example
    volcano 快速开始
  • 原文地址:https://www.cnblogs.com/sosoman/p/2171795.html
Copyright © 2020-2023  润新知