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初步介绍中,我们介绍了官方入门文档的第一章.今天继续给大家介绍官方文档中,如何获取数据源的相关内容.虽然是英文,但 ...
随机推荐
- ubuntu git生成ssh key (公钥私钥)配置github或者码云
Git是分布式的代码管理工具,远程的代码管理是基于SSH的,所以要使用远程的Git则需要SSH的配置. github的SSH配置如下: 设置Git的user name和email: git confi ...
- PyCharm:ModuleNotFoundError: No module named 'HTMLTestRunner'
PyCharm找不到HTMLTestRunner,还是之前的原因PyCharm和之前命令行安装使用的不是一套资源,需要重新导入 查看旧HTMLTestRunner的路径 在PyCharm找到同样类似的 ...
- IP相关的方法
1.验证是否为IP地址 def isIP(ip, with_netmask=True): """ 判断IP的格式是否正确 :param ip: IP字符串 :param ...
- android BSP移植综述
将android移植到特定硬件平台上,其核心是bsp的搭建工作,bsp是板级支持包,并不是特定某个文件,而是从功能上理解的一种硬件适配软件包,它的核心就是: 1. linux内核硬件相关部分(主要是l ...
- .NET基金会成立
作者 Jonathan Allen ,译者 臧秀涛 发布于 2014年4月8日 随着.NET基金会的成立,微软在成为主要的开源参与者的道路上又前进了一步.该基金会的宗旨是“成为越来越多的开源.NET项 ...
- TCC(Tiny C Compiler)介绍
TCC是一个超小.超快的标准C语言编译器.她可以从这里(http://bellard.org/tcc/)下载到:注意,要下载http://download.savannah.nongnu.org/re ...
- tyvj1172自然数拆分
题目:http://www.joyoi.cn/problem/tyvj-1172 非常水的完全背包.物品就是1~n这n个数. 第6行有橙色的警告:this decimal constant is un ...
- Go 的类型断言type assertion
Go语言中的类型断言,语法上是这样的: x.(T) 其中,x是interface接口的表达式,T是类型,称为被断言类型. 补充一下,接口有接口值的概念,其包括动态类型和动态值两部分. 类型断言根据T的 ...
- Input输入控制
1.Input只能输入正整数 <html> <head> <title>只能输入正整数</title> </head> <body&g ...
- BASIC-11_蓝桥杯_十六进制转十进制
注意事项: 1.长数据注意选择long long类型,用%ldd输出,防止数据溢出; 示例代码: #include <stdio.h>#include <string.h>#i ...