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

  • 相关阅读:
    POJ 2112 Optimal Milking (Floyd+二分+最大流)
    hdu5444 Elven Postman
    hdu5442 Favorite Donut
    hdu5437 Alisha’s Party
    hdu5433 Xiao Ming climbing
    hdu5432 Pyramid Split
    Codeforces Round #316 (Div. 2) C. Replacement
    hdu5396 Expression
    hdu3506 Monkey Party
    hdu3516 Tree Construction
  • 原文地址:https://www.cnblogs.com/aiwz/p/6333174.html
Copyright © 2011-2022 走看看