程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> C語言 >> C++ >> C++入門知識 >> C++Precept和NV類的封裝

C++Precept和NV類的封裝

編輯:C++入門知識

C++ Precept和NV類的封裝,請看下面考試大為您收集的代碼:
  1 #pragma once

  2 #include "..StringNWString.h"

  3 #include "..AutoPtrAutoPtr.h"

  4 #include "..CommonList.h"

  5

  6 #define Type_Match_Content                                                0        // 匹配值

  7 #define Type_Match_Rule                                                    1        // 匹配一條表達式

  8 #define Type_Or                                                           -1

  9 #define Type_Choose                                                       -2

  10 #define Type_Loop_0                                                       -3

  11 #define Type_Loop_1                                                       -4

  12 #define Type_Opt                                                       -5

  13 #define Type_LQ                                                           -6

  14 #define Type_RQ                                                           -7

  15

  16 class Precept

  17 {

  18 public:

  19     int Left;

  20     List<int> Right;

  21

  22     Precept() : Left(0){}

  23     Precept(int L,List<int> R) : Left(L),Right(R){}

  24

  25     // +Precept

  26     friend NAutoPtr<Precept> operator+(NAutoPtr<Precept> P)

  27     {

  28         NAutoPtr<Precept> p = new Precept;

  29         p->Right.Add(Type_Loop_1);

  30         p->Right.Add(Type_LQ);

  31         p->Right.Add(P->Right);

  32         p->Right.Add(Type_RQ);

  33         return p;

  34     }

  35

  36     // Precept + Precept

  37     friend NAutoPtr<Precept> operator+(NAutoPtr<Precept> P1,NAutoPtr<Precept> P2)

  38     {

  39         NAutoPtr<Precept> p = new Precept;

  40         p->Right.Add(P1->Right);

  41         p->Right.Add(P2->Right);

  42         return p;

  43     }

  44

  45     // *Precept

  46     friend NAutoPtr<Precept> operator*(NAutoPtr<Precept> P)

  47     {

  48         NAutoPtr<Precept> p = new Precept;

  49         p->Right.Add(Type_Loop_0);

  50         p->Right.Add(Type_LQ);

  51         p->Right.Add(P->Right);

  52         p->Right.Add(Type_RQ);

  53         return p;

  54     }

  55

 56     // Precept | Precept

  57     friend NAutoPtr<Precept> operator|(NAutoPtr<Precept> P1,NAutoPtr<Precept> P2)

  58     {

  59         NAutoPtr<Precept> p = new Precept;

  60         p->Right.Add(Type_LQ);

  61         p->Right.Add(P1->Right);

  62         p->Right.Add(Type_RQ);

  63         p->Right.Add(Type_Or);

  64         p->Right.Add(Type_LQ);

  65         p->Right.Add(P2->Right);

  66         p->Right.Add(Type_RQ);

  67         return p;

  68     }

  69 };

  70

  71 class NV

  72 {

  73 public:

  74     NWString

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved