class在c语言中,C语言中的class的应用 |
您所在的位置:网站首页 › c语言中ack什么意思 › class在c语言中,C语言中的class的应用 |
C语言中的class的应用 答案:6 信息版本:手机版 解决时间 2019-10-04 20:09 已解决 2019-10-04 16:32 C语言中的class的应用 最佳答案 2019-10-04 17:57 1、C语言里没有class函数的概念,class是C++中的关键字。 2、C++是基于C的一种面向对象扩展,它在C原有结构体(struct)的基础上,扩充了struct的功能(增加了成员函数,以及访问控制,继承等),并增加了class这一新定义。实际上class和struct的唯一区别就是:struct中的默认访问控制权限是public,而class的默认访问控制权限是private。 struct RecTangle{ int width; int height; int pos_x; int pos_y; }; 给他添加一些成员函数 struct RecTangle{ int width; int height; int pos_x; int pos_y; int Right(); // get right int Bottom(); // get bottom int Left(); // get left int Top(); // get top }; 为了隐藏结构体内的成员,添加访问控制标识: struct RecTangle{ private: int width; int heig |
今日新闻 |
点击排行 |
|
推荐新闻 |
图片新闻 |
|
专题文章 |
CopyRight 2018-2019 实验室设备网 版权所有 win10的实时保护怎么永久关闭 |