菜菜

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

随笔分类 -  c++

摘要:代码: 会调用参数为int && 的[]重载函数,也就是 注意此函数不能返回const int&,因为不能给一个const赋值。 这句话的含义是 先t[1],然后赋值i 阅读全文
posted @ 2019-07-29 23:50 好吧,就是菜菜 阅读(285) 评论(0) 推荐(0) 编辑

摘要:隐式转换 在赋值给一个兼容类型会出现隐式类型转换.比如下面这个例子. 在以上例子中.值从short自动提升到int,这是标准转换。标准转换影响基本数据类型,它在类型数字类型之间(short to int, int to float, double to int...), 布尔类型和一些指针之间执行。 阅读全文
posted @ 2019-07-02 08:41 好吧,就是菜菜 阅读(1761) 评论(0) 推荐(0) 编辑

摘要:不会用就直接复制粘贴 阅读全文
posted @ 2019-01-14 19:31 好吧,就是菜菜 阅读(660) 评论(0) 推荐(0) 编辑

摘要:原文地址:https://en.cppreference.com/w/cpp/container/map/map 阅读全文
posted @ 2018-07-21 23:08 好吧,就是菜菜 阅读(695) 评论(0) 推荐(0) 编辑

摘要:#include #include #include #include #include using namespace std; int main() { //freopen("d://1.text", "r", stdin); map *maps = new map(); maps->insert(pair(0, "0")); maps->i... 阅读全文
posted @ 2018-07-21 21:59 好吧,就是菜菜 阅读(212) 评论(0) 推荐(0) 编辑

摘要:输出 for end //循环结束输出delete //删除pp对象main end //main函数结束 //下面是5个delete 和 const int NN=5对应 delete deletedeletedeletedelete //所以, delete 0 永远都是安全的 //注意前面有个 阅读全文
posted @ 2018-06-11 00:26 好吧,就是菜菜 阅读(259) 评论(0) 推荐(0) 编辑

摘要:#include using namespace std; class Example5 { string* ptr; public: Example5(const string& str):ptr(new string(str)){} ~Example5(){delete ptr;} //copy constructo... 阅读全文
posted @ 2018-02-15 22:08 好吧,就是菜菜 阅读(142) 评论(0) 推荐(0) 编辑

摘要:模版函数和模版类 下面这个模式就有点奇怪了 阅读全文
posted @ 2018-02-14 23:58 好吧,就是菜菜 阅读(230) 评论(0) 推荐(0) 编辑

摘要:#include using namespace std; class MyClass { public: int x; static int n; const int y; MyClass(int val) : x(val), y(20) { } // ... 阅读全文
posted @ 2018-02-14 23:04 好吧,就是菜菜 阅读(157) 评论(0) 推荐(0) 编辑

摘要:#include using namespace std; class Dummy { public: static int n; int x; Dummy() : x(0) { n++; } Dummy(int xx) ... 阅读全文
posted @ 2018-02-14 16:35 好吧,就是菜菜 阅读(134) 评论(0) 推荐(0) 编辑

摘要:#include using namespace std; class Dummy { public: int x; Dummy() : x(0) { } ; Dummy(int xx) : x(xx) { } ; bool isitem(Dummy const&)... 阅读全文
posted @ 2018-02-14 16:04 好吧,就是菜菜 阅读(310) 评论(0) 推荐(0) 编辑

摘要:#include using namespace std; class CVector { public: int x, y; CVector() : x(0), y(0) { } CVector(int a, int b) : x(a), y(b) { } ; CVect... 阅读全文
posted @ 2018-02-14 15:46 好吧,就是菜菜 阅读(149) 评论(0) 推荐(0) 编辑

摘要:#include using namespace std; class Circle { double radius; public: Circle(double r) { radius = r; } double area() { return 2 * radius; } }; class Cylind... 阅读全文
posted @ 2018-01-27 17:44 好吧,就是菜菜 阅读(226) 评论(0) 推荐(0) 编辑

摘要:#include #include #include using namespace std; /** * url:http://www.cplusplus.com/doc/tutorial/other_data_types/ */ /** * in which all its member elements occupy the same physical space in memor... 阅读全文
posted @ 2018-01-01 01:27 好吧,就是菜菜 阅读(193) 评论(0) 推荐(0) 编辑

摘要:#include #include using namespace std; int main() { /** * 动态内存 * url: http://www.cplusplus.com/doc/tutorial/dynamic/ * 关键字new用于在程序运行时动态开辟内存,内存开辟在堆空间. * 此关键字不保证内存一定开辟成功,如果开辟... 阅读全文
posted @ 2018-01-01 00:38 好吧,就是菜菜 阅读(154) 评论(0) 推荐(0) 编辑

摘要:++的操作高于* 阅读全文
posted @ 2017-12-31 01:01 好吧,就是菜菜 阅读(198) 评论(0) 推荐(0) 编辑

摘要:#include #include #include #include #include #include #include #include #include #include #include using namespace std; /** * 命名空间 * *namespace identifier *{ * named_entities *} */ nam... 阅读全文
posted @ 2017-12-10 17:25 好吧,就是菜菜 阅读(209) 评论(0) 推荐(0) 编辑

摘要:#include #include #include #include #include #include #include #include #include #include #include using namespace std; /** * 重载,函数有不同数目的参数或者是不同类型的参数 */ int operate(int a, int b) { return (... 阅读全文
posted @ 2017-12-10 16:58 好吧,就是菜菜 阅读(250) 评论(0) 推荐(0) 编辑

摘要:#include #include #include #include #include #include #include #include #include #include #include using namespace std; /** * Calling a function with parameters taken by value causes copies o... 阅读全文
posted @ 2017-12-10 13:03 好吧,就是菜菜 阅读(848) 评论(0) 推荐(0) 编辑

摘要:来自官方文档。。。感谢老王指出需要c++11,一下代码全在c++11下编译,编译参数加入 -std=c++11 阅读全文
posted @ 2017-12-10 00:44 好吧,就是菜菜 阅读(5563) 评论(0) 推荐(0) 编辑