c++官方文档-class
#include <iostream>
using namespace std; class Circle
{
double radius;
public:
Circle(double r)
{
radius = r;
}
double area()
{
return * radius;
}
};
class Cylinder
{
Circle base;
double height;
public:
Cylinder(double r, double h)
: base(r), height(h)
{
}
double volume()
{
return base.area() * height;
}
};
//uniform initializer
//Cylinder::Cylinder(double r, double h)
// : base { r }, height { h }
//{
//}
class Rectangle
{
int width, height;
public:
Rectangle();
Rectangle(int, int);
void set_values(int, int);
int area(void)
{
return width * height;
}
;
};
Rectangle::Rectangle()
{
width = ;
height = ;
}
Rectangle::Rectangle(int x, int y)
: width(x), height(y)
{
} //Rectangle::Rectangle(int a, int b)
//{
// width = a;
// height = b;
//}
void Rectangle::set_values(int x, int y)
{
width = x;
height = y;
} int main()
{
Rectangle rect(, );
int myarea = rect.area();
cout << myarea << endl;
// Circle foo(10.0); // functional form
Circle bar = 20.0; // assignment init.
Circle baz { 30.0 }; // uniform init.
Circle qux = { 40.0 }; // POD-like
// cout << foo.area() << endl;
cout << bar.area() << endl;
cout << baz.area() << endl;
cout << qux.area() << endl;
Rectangle rectb; // default constructor called
Rectangle rectc(); // function declaration (default constructor NOT called)
Rectangle rectd { }; // default constructor called Cylinder foo(, );
cout << "foo's volume: " << foo.volume() << '\n';
Rectangle* foop;
foop = ▭
cout << foop->area() << endl;
delete foop;
return ;
}
c++官方文档-class的更多相关文章
- 【AutoMapper官方文档】DTO与Domin Model相互转换(上)
写在前面 AutoMapper目录: [AutoMapper官方文档]DTO与Domin Model相互转换(上) [AutoMapper官方文档]DTO与Domin Model相互转换(中) [Au ...
- 2DToolkit官方文档中文版打地鼠教程(三):Sprite Collections 精灵集合
这是2DToolkit官方文档中 Whack a Mole 打地鼠教程的译文,为了减少文中过多重复操作的翻译,以及一些无必要的句子,这里我假设你有Unity的基础知识(例如了解如何新建Sprite等) ...
- 2DToolkit官方文档中文版打地鼠教程(二):设置摄像机
这是2DToolkit官方文档中 Whack a Mole 打地鼠教程的译文,为了减少文中过多重复操作的翻译,以及一些无必要的句子,这里我假设你有Unity的基础知识(例如了解如何新建Sprite等) ...
- 2DToolkit官方文档中文版打地鼠教程(一):初始设置
这是2DToolkit官方文档中 Whack a Mole 打地鼠教程的译文,为了减少文中过多重复操作的翻译,以及一些无必要的句子,这里我假设你有Unity的基础知识(例如了解如何新建Sprite等) ...
- 【AutoMapper官方文档】DTO与Domin Model相互转换(中)
写在前面 AutoMapper目录: [AutoMapper官方文档]DTO与Domin Model相互转换(上) [AutoMapper官方文档]DTO与Domin Model相互转换(中) [Au ...
- 【AutoMapper官方文档】DTO与Domin Model相互转换(下)
写在前面 AutoMapper目录: [AutoMapper官方文档]DTO与Domin Model相互转换(上) [AutoMapper官方文档]DTO与Domin Model相互转换(中) [Au ...
- Ionic2系列——Ionic 2 Guide 官方文档中文版
最近一直没更新博客,业余时间都在翻译Ionic2的文档.之前本来是想写一个入门,后来觉得干脆把官方文档翻译一下算了,因为官方文档就是最好的入门教程.后来越翻译越觉得这个事情确实比较费精力,不知道什么时 ...
- Kotlin开发语言文档(官方文档)-- 目录
开始阅读Kotlin官方文档.先上文档目录.有些内容还未阅读,有些目录标目翻译还需琢磨琢磨.后续再将具体内容的链接逐步加上. 文档链接:https://kotlinlang.org/docs/kotl ...
- 一起学微软Power BI系列-官方文档-入门指南(1)Power BI初步介绍
我们在前一篇文章微软新神器-Power BI,一个简单易用,还用得起的BI产品中,我们初步介绍了Power BI的基本知识.由于Power BI是去年开始微软新发布的一个产品,虽然已经可以企业级应用, ...
- 一起学微软Power BI系列-官方文档-入门指南(2)获取源数据
我们在文章: 一起学微软Power BI系列-官方文档-入门指南(1)Power BI初步介绍中,我们介绍了官方入门文档的第一章.今天继续给大家介绍官方文档中,如何获取数据源的相关内容.虽然是英文,但 ...
随机推荐
- [LeetCode&Python] Problem 575. Distribute Candies
Given an integer array with even length, where different numbers in this array represent different k ...
- 与众不同 制作会唱歌的WinRAR - imsoft.cnblogs
为了使用方便,我们可能会把RAR压缩包制作成自解压文件.WinRAR自带的自解压模块虽然使用很方便,但千篇一律的外观看起来实在 乏味.其实,只要通过简单改造,你就可以制作出与众不同,声色俱佳的WinR ...
- Java/JDK安装教程手册(正规图文全流程)、运行、环境配置
Java/JDK教程手册 本文提供全流程,中文翻译.Chinar坚持将简单的生活方式,带给世人!(拥有更好的阅读体验 -- 高分辨率用户请根据需求调整网页缩放比例) 一 Download Resouc ...
- Java乱码解决之道
1.常见字符编码 ASCII编码: ASCII,American Standard Code for Information Interchange,是基于拉丁字母的一套电脑编码系统,主要用于显示现代 ...
- M端错误提醒 -- pop 使用
JS: window.pop = {/*alert提示框 *@param title 提示的标题 *@param desc 提示的描述 *@param btnNum 按钮的数量,假如为1,则无视e2, ...
- 51Nod 1066:Bash游戏 (巴什博弈)
1066 Bash游戏 基准时间限制:1 秒 空间限制:131072 KB 分值: 0 难度:基础题 收藏 关注 有一堆石子共有N个.A B两个人轮流拿,A先拿.每次最少拿1颗,最多拿K颗,拿到 ...
- HPU 1007: 严格递增连续子段(贪心)
1007: 严格递增连续子段 [模拟] 时间限制: 1 Sec 内存限制: 128 MB提交: 244 解决: 18 统计 题目描述 给定一个有NN个正整数组成的序列,你最多可以改变其中一个元素,可以 ...
- VS2013、VS2015中,新建项目没有看到解决方案的问题(已解决)
问题描述:装好VS2013 专业版 for Update5不知怎么弄的,突然新建项目没有了解决方案,于是各种折腾,最后终于解决了! ================================== ...
- CTF之猪圈密码
猪圈密码又称济会密码,朱高密码,是一种简单的替代密码,所以安全性很低
- Python编码——常见的编码设置
1.查看自己电脑的python的编码设置 # -*- coding: utf8 -*- import sys, locale """ locale.getpreferre ...