
C/C++
点十八
成就一番伟业的唯一途径就是热爱自己的事业。如果你还没能找到让自己热爱的事业,继续寻找,不要放弃。跟随自己的心,总有一天你会找到的。
展开
-
[c++]子类私有的虚函数,多态问题
运行时也不会报错。因为函数的访问权限应该只在编译期有,编译成机器码就已经没有访问权限控制了。所以最终,应该是可以编译,也可以运行。这个特点等于为我们提供了一个强制使用子类的程序员必须使用基类的指针来调用子类实现的函数,而达到多态的目的,因为子类的函数,用子类对象直接使用时,没有访问权限。#include using namespace std; class Base { publ原创 2014-08-03 17:04:29 · 1415 阅读 · 0 评论 -
C/C++中 变量的存储位置,BSS段
内容转自:http://www.docin.com/p-210019581.html 感谢分享。转载 2014-11-22 22:38:21 · 2142 阅读 · 0 评论 -
STL应用之大根堆小根堆
STL应用之大根堆小根堆定义:priority_queue xxx 大根堆priority_queue, greater> xxxx 小根堆原创 2014-10-15 21:24:26 · 14556 阅读 · 0 评论 -
c++ int转化为string 类型
#include 里面有to_string的函数可以写s=std::to_string(x),有多个重载,x是整型的或浮点型的,即x为内置数值类型就可以。原创 2014-10-29 16:40:37 · 1637 阅读 · 0 评论 -
C++ lambda 表达式传递的变量默认不可变
我遇到如下问题:int count=0; listener->onTouchMoved=[count](Touch* t,Event* e){ count++; log("onTouchMoved"); };Xcode下的编译错误为:Cannot assign to a variable captured by copy原创 2014-10-28 12:20:52 · 4894 阅读 · 0 评论 -
标准C++中的string类的用法总结
原文转自:http://www.cnblogs.com/xFreedom/archive/2011/05/16/2048037.html转载 2014-10-24 19:11:52 · 427 阅读 · 0 评论 -
C++中cin、cin.get()、cin.getline()、getline()、gets()等函数的用法
原文转自:http://www.cnblogs.com/flatfoosie/archive/2010/12/22/1914055.html转载 2014-10-24 18:48:38 · 452 阅读 · 0 评论 -
使用gets()和scanf()应该注意的地方
假设输入数据格式为,第一行为原创 2014-10-24 10:07:40 · 708 阅读 · 0 评论 -
[c++]为什么可以在基类中实现纯虚函数
引述自:http://forums.codeguru.com/showthread.php?356281-C-why-pure-virtual-function-has-definition-Please-look-into-sample-code-here转载 2014-08-02 19:37:13 · 4161 阅读 · 0 评论 -
c++里string转ing的函数
有两种方法1. c++中string到int的转换1) 在C标准库里面,使用atoi: #include #include std::string text = "152"; int number = std::atoi( text.c_str() ); if (errno == ERANGE) //可能是std::errno {转载 2014-11-25 09:43:13 · 1570 阅读 · 0 评论