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);
    }

  • 相关阅读:
    FileDescriptor详解
    java序列化
    ObjectInputStream和ObejctOutputStream
    ByteArrayOutputStream
    ByteArrayInputStream
    PipedInputStream/PipedOutputStream
    字节输入流
    反义
    贪婪和非贪婪
    MYSQL数据库优化
  • 原文地址:https://www.cnblogs.com/aiwz/p/6333174.html
Copyright © 2011-2022 走看看