Encapsulation of C ++ Precept and NV classes

Source: Internet
Author: User

For the encapsulation of C ++ Precept and NV classes, see the code collected by the following exam:
1 # pragma once

2 # include "... StringNWString. h"

3 # include "... AutoPtrAutoPtr. h"

4 # include "... CommonList. h"

5

6 # define Type_Match_Content 0 // matching Value

7 # define Type_Match_Rule 1 // match an expression

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

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

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

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

62 p-> Right. Add (Type_RQ );

63 p-> Right. Add (Type_Or );

64 p-> Right. Add (type_scsi );

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.