博客
关于我
(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/

你可能感兴趣的文章
phpstorm 2016.3.3 激活
查看>>
phpstorm中Xdebug的使用
查看>>
phpstorm中使用svn版本控制器
查看>>
phpstorm配置php脚本执行
查看>>
PhpStorm配置远程xdebug
查看>>
phpStudy安装教程
查看>>
phpunit
查看>>
phpweb成品网站最新版(注入、上传、写shell)
查看>>
phpWhois 项目推荐
查看>>
Redis事务详解,吃透数据库没你想的那么难
查看>>
phpwind部署问题
查看>>
PHP_CodeIgniter Github实现个人空间
查看>>
php_crond:一个基于多进程的定时任务系统-支持秒粒度的任务配置
查看>>
PHP__call __callStatic
查看>>
PHP——修改数据库1
查看>>
PHP——封装Curl请求方法支持POST | DELETE | GET | PUT 等
查看>>
PHP——底层运行机制与原理
查看>>
php一句话图片运行,【后端开发】php一句话图片木马怎么解析
查看>>
PHP三方登录,移动端与服务端交互
查看>>
PHP上传文件大小限制的调整 Nginx 413 Request Entity Too Large
查看>>