c++类指针
来源:互联网 发布:深圳乐易网络双休吗 编辑:程序博客网 时间:2024/06/09 19:07
#include <iostream>using namespace std;class Rectangle { int width, height;public: Rectangle (int x, int y) : width(x), height(y) {} int area (void) {return width * height;}};int main(int argc, char const *argv[]){ Rectangle obj (3, 4); Rectangle * foo, * bar, * baz; foo = & obj; bar = new Rectangle (5, 6); baz = new Rectangle [2] {{2, 5}, {3, 6}}; cout << "obj's area: " << obj.area() << '\n'; cout << "*foo's area: " << foo->area() << '\n'; cout << "*bar's area: " << bar->area() << '\n'; cout << "baz[0]'s area:" << baz[0].area() << '\n'; cout << "baz[1]'s area:" << baz[1].area() << '\n'; delete bar; delete[] baz; return 0;}
阅读全文
0 0
- 【C++】指向类的指针
- c语言指针类问题
- C指针的指针
- c 指针的指针
- C--指针
- C-指针
- C指针
- C指针
- C指针
- C---指针
- c 指针
- C指针
- C指针
- C指针
- C 指针
- c指针
- C指针
- C 指针
- 提高代码可读性的10个技巧
- DP第二周作业
- bugdone使用
- Spring--4.bean管理(xml)
- js创建对象几种方式
- c++类指针
- 阿里发布的规约插件
- MongoDB sharding模式实现(http://blog.chinaunix.net/xmlrpc.php?r=blog/article&uid=28266791&id=5758139 )
- Altium Designer 16快捷键列表
- 设计模式【状态模式State Pattern】
- 监听、控制软键盘的弹出和收起
- Init进程笔记
- altera FPGA介紹
- Fiddler 手机抓包步骤