#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 = &rect;
cout << foop->area() << endl;
delete foop;
return ;
}

c++官方文档-class的更多相关文章

  1. 【AutoMapper官方文档】DTO与Domin Model相互转换(上)

    写在前面 AutoMapper目录: [AutoMapper官方文档]DTO与Domin Model相互转换(上) [AutoMapper官方文档]DTO与Domin Model相互转换(中) [Au ...

  2. 2DToolkit官方文档中文版打地鼠教程(三):Sprite Collections 精灵集合

    这是2DToolkit官方文档中 Whack a Mole 打地鼠教程的译文,为了减少文中过多重复操作的翻译,以及一些无必要的句子,这里我假设你有Unity的基础知识(例如了解如何新建Sprite等) ...

  3. 2DToolkit官方文档中文版打地鼠教程(二):设置摄像机

    这是2DToolkit官方文档中 Whack a Mole 打地鼠教程的译文,为了减少文中过多重复操作的翻译,以及一些无必要的句子,这里我假设你有Unity的基础知识(例如了解如何新建Sprite等) ...

  4. 2DToolkit官方文档中文版打地鼠教程(一):初始设置

    这是2DToolkit官方文档中 Whack a Mole 打地鼠教程的译文,为了减少文中过多重复操作的翻译,以及一些无必要的句子,这里我假设你有Unity的基础知识(例如了解如何新建Sprite等) ...

  5. 【AutoMapper官方文档】DTO与Domin Model相互转换(中)

    写在前面 AutoMapper目录: [AutoMapper官方文档]DTO与Domin Model相互转换(上) [AutoMapper官方文档]DTO与Domin Model相互转换(中) [Au ...

  6. 【AutoMapper官方文档】DTO与Domin Model相互转换(下)

    写在前面 AutoMapper目录: [AutoMapper官方文档]DTO与Domin Model相互转换(上) [AutoMapper官方文档]DTO与Domin Model相互转换(中) [Au ...

  7. Ionic2系列——Ionic 2 Guide 官方文档中文版

    最近一直没更新博客,业余时间都在翻译Ionic2的文档.之前本来是想写一个入门,后来觉得干脆把官方文档翻译一下算了,因为官方文档就是最好的入门教程.后来越翻译越觉得这个事情确实比较费精力,不知道什么时 ...

  8. Kotlin开发语言文档(官方文档)-- 目录

    开始阅读Kotlin官方文档.先上文档目录.有些内容还未阅读,有些目录标目翻译还需琢磨琢磨.后续再将具体内容的链接逐步加上. 文档链接:https://kotlinlang.org/docs/kotl ...

  9. 一起学微软Power BI系列-官方文档-入门指南(1)Power BI初步介绍

    我们在前一篇文章微软新神器-Power BI,一个简单易用,还用得起的BI产品中,我们初步介绍了Power BI的基本知识.由于Power BI是去年开始微软新发布的一个产品,虽然已经可以企业级应用, ...

  10. 一起学微软Power BI系列-官方文档-入门指南(2)获取源数据

    我们在文章: 一起学微软Power BI系列-官方文档-入门指南(1)Power BI初步介绍中,我们介绍了官方入门文档的第一章.今天继续给大家介绍官方文档中,如何获取数据源的相关内容.虽然是英文,但 ...

随机推荐

  1. C# 使用GZip对字符串压缩和解压

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.I ...

  2. JS Array.filter()方法

    1.filter()接收的函数可以有多个参数.通常我们只使用第一个参数,第二参数和第三个参数表示元素的位置和数组本身: //去重 var arr = ["1", "2&q ...

  3. (精)字符串,map -> json对象->map(初学者必读)

    import java.util.LinkedList; import java.util.*; import java.util.ListIterator; import net.sf.json.J ...

  4. zz 【见闻八卦】《金融时报》年度商业书单:互联网题材占一半

    [见闻八卦]<金融时报>年度商业书单:互联网题材占一半 文 / 见闻学堂 2014年12月18日 09:47:38 0   中国最好的金融求职培训:见闻学堂(微信号:top-elites) ...

  5. 一份11gR2 rac awr报告的简单分析

    昨晚网友发来一份awr报告,希望帮忙分析一下.由于其他信息都没有,仅仅只有一份awr,鉴于目前有大多的朋友还不太熟悉或者说不知道如何去进行awr的分析.我这里就拿这个awr来进行分析,当抛砖引玉了.首 ...

  6. RAC7——vip的理解

    VIP特点: 1 VIP是在clusterware安装最后阶段,通过脚本VIPCA创建的: 2 VIP作为一个Nodeapps类型的CRS Resource注册到OCR中,并由CRS维护状态: 3 V ...

  7. linux 命令 随笔

    1 查找命令 which (寻找执行档) :这个指令是根据PATH这个环境变量所规范的路径,去搜寻执行档的档名,所以,重点是找出执行档而已,which 后面接的是完整档名,也就说执行文件 wherei ...

  8. golang kafka client

    针对golang的 kafka client 有很多开源package,例如sarama, confluent等等.在使用sarama 包时,高并发中偶尔遇到crash.于是改用confluent-k ...

  9. php中二维数组排序问题方法详解

    PHP中二维数组排序,可以使用PHP内置函数uasort() 示例一: 使用用户自定义的比较函数对数组中的值进行排序并保持索引关联 回调函数如下:注意回调函数的返回值是负数或者是false的时候,表示 ...

  10. Linux中CPU亲和性(go)

    http://www.cnblogs.com/LubinLew/p/cpu_affinity.html