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

你可能感兴趣的文章
Objective-C实现高斯消除算法(附完整源码)
查看>>
Objective-C实现高斯滤波GaussianBlur函数用法(附完整源码)
查看>>
Objective-C语法之代码块(block)的使用
查看>>
Objenesis创建类的实例
查看>>
OBObjective-c 多线程(锁机制) 解决资源抢夺问题
查看>>
OBS studio最新版配置鉴权推流
查看>>
ObsoleteAttribute 可适用于除程序集、模块、参数或返回值以外的所有程序元素。 将元素标记为过时可以通知用户:该元素在产品的未来版本中将被移除。...
查看>>
OC Xcode快捷键
查看>>
oc 中的.m和.mm文件区别
查看>>
OC 内存管理黄金法则
查看>>
oc57--Category 分类
查看>>
occi库在oracle官网的下载针对vs2008
查看>>
OceanBase 安装使用详细说明
查看>>
OceanBase详解及如何通过MySQL的lib库进行连接
查看>>
OCP题库升级,新版的052考试题及答案整理-18
查看>>
OCR使用总结
查看>>
OfficeWeb365 SaveDraw 文件上传漏洞复现
查看>>
office中的所有content type
查看>>
office之Excel 你会用 Ctrl + E 吗?
查看>>
Office办公软件里的“开发工具”选项卡-ChatGPT4o作答
查看>>