博客
关于我
(25.2)类的定义之类的数据成员,类的成员函数,类的声明
阅读量:406 次
发布时间:2019-03-05

本文共 2190 字,大约阅读时间需要 7 分钟。

???????????

? C++ ??????????????????????????????????????????????????????????????


1. ??????

????????????????????????????????void???const???????????????????????

  • ???????

    ????????????????????????????????????????????????????

    class Cube {  long color; // ????  double x, y, z, side; // ????};
  • ???????

    ?????????????????????????????????void???const??????

    class ADT {  long color;  double x, y, z, side;  int a[10]; // ??  char *s; // ??  char &r; // ??  void *p; // void??};
  • ????

    ???????????????member object???????????????????

    class Point {  public:  void set(int a, int b) {}  int x, y;};class Line {  public:  void set(Point a, Point b) {}  Point start, end; // ????};

2. ????????

?????????????????????????????????????????????????????

  • ????

    ??????????????????????????

    class ADT {  struct Point {    int x, y;  };  union UData {    Point p;    long color;  };  enum COLORS { RED, GREEN, BLUE, BLACK, WHITE };  typedef Point* LPPOINT;};

3. ??????

????????????????????????????????????????

  • ?????????

    ????????????????????????????????????????????

    void Data::set(int d) {  data = d;}

    ???:: ????????????????? Data??????????????? ???? ??::??? ??????

  • ??????

    ????????????????inline??????????????????????????????C++?????????????????????? inline ???????????

    class Data {  int getx() { return x; }  inline int gety() { return y; }  void setxy(int _x, int _y) {    x = _x;    y = _y;  }};

4. ????????????

????????????????????????????????????????????????????????

  • ????
    class MAX {  int Max(int x, int y) { return x > y ? x : y; }  int Max() { return Max(Max(a, b), Max(c, d)); }  int Set(int i = 1, int j = 1, int k = 3, int l = 4) {    a = i;    b = i;    c = k;    d = l;  }};

5. ?????????

??????????????????????????????????????????????????????????????????????????????????

  • ??
    class Time {  int h, m, s;  void settime(int a, int b, int c) {    h = a;    m = b;    s = c;  }};sizeof(Time) = 12;

6. ???????

  • ???

    ????????????? }???????????????

  • ????

    ?????????????????????

    class Point; // ???

    ??????????????????????????????????????????????????????????


7. ??????????????

  • ????

    ?????????????????????????????????????

  • ????

    ??????????????????????????????????????????????????????


?????????????????????????????????????????????

转载地址:http://ilyzz.baihongyu.com/

你可能感兴趣的文章
php rss,如何用PHP编写RSS
查看>>
php session超时时间_php怎么设置session超时时间
查看>>
PHP SOAP模块的使用方法:NON-WSDL模式
查看>>
PHP Socket实现websocket(三)Stream函数
查看>>
php Socket通信
查看>>
PHP SPL标准库-迭代器
查看>>
php static 变量
查看>>
PHP Static延迟静态绑定
查看>>
php str_pad();
查看>>
PHP study 环境变量composer
查看>>
PHP trim() 函数
查看>>
php unicode编码转成unioce字符(中文)
查看>>
php url路径问题和php文件以绝对路径引入
查看>>
PHP WebSehll 后门脚本与检测工具
查看>>
ReentrantLock源码解析
查看>>
PHP XSS攻击防范--如何过滤用户输入
查看>>
php zookeeper实现分布式锁
查看>>
PHP 中 this,self,parent 的区别、用法
查看>>
PHP 中如何高效地处理大规模数据的排序?
查看>>
PHP 之ftp客户端类封装实现
查看>>