zoukankan      html  css  js  c++  java
  • 考考你的C++水平

    指出执行NoSwitchTest函数的执行结果,并说明执行过程。

    enum FACE_TYPE
    {
     FACE_XY,
     FACE_XZ,
     FACE_YZ
    };

    template<int faceType>
    class Face
    {
    public:
     enum {FACE_TYPE = faceType};
     virtual void Draw() = 0;
    };

    class FaceOp
    {
    public:
     template<int type>
     void actionSpecial(Face<type>& T)
     {
      _actionSpecial(T);
     }
     template<int type>
     void actionCommon(Face<type>& T)
     {
      std::cout << "this is the action common/n";
     }
    private:
     void _actionSpecial(Face<FACE_XY>)
     {
      std::cout << "   this is the action FACE_XY/n";
     }
     void _actionSpecial(Face<FACE_XZ>)
     {
      std::cout << "   this is the action FACE_XZ/n";
     }
     void _actionSpecial(Face<FACE_YZ>)
     {
      std::cout << "   this is the action FACE_YZ/n";
     }
    };

    class FaceXY : public Face<FACE_XY>
    {
    public:
     void Draw()
     {
      std::cout << "Draw FACE_XY/n";
     }
    };

    class FaceXZ : public Face<FACE_XZ>
    {
    public:
     void Draw()
     {
      std::cout << "Draw FACE_XZ/n";
     }
    };

    class FaceYZ : public Face<FACE_YZ>
    {
    public:
     void Draw()
     {
      std::cout << "Draw FACE_YZ/n";
     }
    };

    inline void NoSwitchTest()
    {

     FaceXY  faceXY;
     FaceXZ  faceXZ;
     FaceYZ  faceYZ;
     FaceOp  faceOp;

     faceOp.actionSpecial(faceXY);
     faceOp.actionSpecial(faceXZ);
     faceOp.actionSpecial(faceYZ);

     faceOp.actionCommon(faceXY);
     faceOp.actionCommon(faceXZ);
     faceOp.actionCommon(faceYZ);
    }

  • 相关阅读:
    asp.net中合并DataGrid行
    将Asp.Net页面输出到EXCEL里去····
    清空Sql数据库日志等操作
    opengl 教程(14) 摄像机控制(1)
    awk使用技巧
    opengl 教程(10) index draw
    opengl 教程(12) 投影矩阵
    opengl 教程(9) 顶点属性插值
    opengl 教程(15) 摄像机控制(2)
    opengl 教程(11) 平移/旋转/缩放
  • 原文地址:https://www.cnblogs.com/aiwz/p/6333174.html
Copyright © 2011-2022 走看看