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初步介绍中,我们介绍了官方入门文档的第一章.今天继续给大家介绍官方文档中,如何获取数据源的相关内容.虽然是英文,但 ...
随机推荐
- Markdown的写法
这里只介绍Markdown的书写格式.在github中显示出来. 当你看到下面两张图片时,你会发现区别还是蛮大的. 标题: 首先>就是最左边的那条竖线,但是=(最高阶标题)和-(第二阶标题). ...
- MVC 模型 视图, 控制器 写 三级联动
<!DOCTYPE html><html> <head> <meta charset="UTF-8"> <title>& ...
- 《DSP using MATLAB》 Problem 4.9
代码: %% ---------------------------------------------------------------------------- %% Output Info a ...
- 来自官方的一些dbt 最佳实践
限制对原始数据的依赖性 您的项目将取决于存储在数据库中的原始数据.我们建议制作所谓的“基本模型”,以最大限度地减少对原始数据表的依赖性.在此约定中,基本模型可以具有以下职责: 仅选择与当前分析相关的字 ...
- 转 web.config设置之system.webServer 详细介绍,为网站设置默认文档
如何:为 IIS 7.0 配置 <system.webServer> 节2008-06-14 22:26http://technet.microsoft.com/zh-cn/sysinte ...
- 协程、gevent实现异步io、进程、线程、协程对比
异步io的说白了就是遇到io操作的时候,就停下来去做别的事情.io分网络io和磁盘io,网络io比如说打开一个网站获取数据,下载一首歌等等,磁盘io就是把数据存到一个文件里面,写到磁盘上. 从网站上获 ...
- 关于 Javascript 严格模式下多文件合并时注意
Javascript 在第一行使用 "use strict" 声明严格模式. 但是在多个 js 文件合并时就需要注意了,可能你的是严格模式,但别的文件不是,就会造成错误. 为什么使 ...
- 处理json的常用java类库:Json-lib(org.json)、Gson、Jackson、Fastjson
更多的处理json的java类库,有人做了性能对比,GitHub地址:https://github.com/fabienrenaud/java-json-benchmark 处理json的java类库 ...
- Joyoi公路乘车(原tyvj1015)
题目:http://www.joyoi.cn/problem/tyvj-1015 水题.连优化都不用. #include<iostream> #include<cstdio> ...
- Ajax异步上传多个文件并返回文件路径
前端JSP页面代码 <label>附件:</label><form id="fileForm"> <input type="fi ...