c++
文章平均质量分 59
xuyaoquanxian
这个作者很懒,什么都没留下…
展开
-
typedef和#define的用法与区别
typedef和#define的用法与区别 一、typedef的用法 在C/C++语言中,typedef常用来定义一个标识符及关键字的别名,它是语言编译过程的一部分,但它并不实际分配内存空间,实例像: typedef int INT; typedef int ARRAY[10]; typedef (int*) pINT; typedef可转载 2016-05-14 21:09:06 · 238 阅读 · 0 评论 -
linux下cmake代码覆盖率
安装两个需要的模块 sudo apt-get install gcov lcov 编译的时候,增加 -fprofile-arcs -ftest-coverage 链接增加-fprofile-arcs 优化-O2以下 打开-g3 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage -O -g3"原创 2018-01-25 12:36:49 · 1110 阅读 · 0 评论 -
按行列创建动态数组(模板)
template bool newArray(T *&Array, int num) { if (num > 0) { Array = new T[num]; } else { std::cout << "num<1" << endl; return false; } assert(Array != nullptr); return true; } template原创 2017-09-07 20:58:44 · 256 阅读 · 0 评论 -
c++与stm32串口通信
原子官方例程: `if(USART_GetITStatus(USART1, USART_IT_RXNE) != RESET) { Res =USART_ReceiveData(USART1); if((USART_RX_STA&0x8000)==0) { if(USART_RX_STA&0x4000) { if(Res!=0x0a原创 2016-06-25 19:45:48 · 2841 阅读 · 0 评论 -
C++类成员初始化列表
Classy::Classy(int n,int m):men1(n),men2(0),men3(n*m+2) { // *** } 1.这种格式只能用于构造函数,2.必须用这种格式初始化非静态const数据成员(c++11之前)3.必须用这种格式来初始化引用数据成员//c++11中允许用更直观的方式 class Classy { int mem1=10; const原创 2017-04-14 15:02:33 · 289 阅读 · 0 评论 -
字符串和数字相互转换
errno_t _itoa_s( int value, char *buffer, size_t sizeInCharacters, int radix ); errno_t _i64toa_s( __int64 value, char *buffer, size_t sizeInCharacters, in转载 2017-04-03 23:39:17 · 773 阅读 · 0 评论 -
OPENCV沿x,y灰度检测
/*************************************************************************************************************************** 沿x,y轴灰度分析 1.文件名格式1.jpg--n.jpg 2.设置文件数 ***********************************原创 2017-04-03 23:32:58 · 601 阅读 · 0 评论 -
c++输入输出/文件流
常用流 cin: cin.get(1/2/3个参数) cin.get(myInt1).get(myInt2).get(myInt3); cin.getline() cin.getline(a,256) cin.ignore() //去掉一个字符 cin.peek() //只看不读 cin.putback() //放回去一个字符原创 2016-06-17 14:06:03 · 337 阅读 · 0 评论 -
c++异常处理(使用虚函数)
#include using namespace std; const int DefaultSize = 10; class Array { public: Array(int itsSize = DefaultSize); ~Array() { delete[] pType; } const int & operator[](int offSet) const; int &原创 2016-06-08 18:22:14 · 488 阅读 · 0 评论 -
c++处理二进制
#include #include #include using namespace std; int main() { bitset a; cout << a << endl; bitset b(0xffff); cout << b << endl; bitset c(0xffff); cout << c << endl; bi原创 2016-06-16 17:44:19 · 627 阅读 · 0 评论 -
c++标准模板库
http://www.cnblogs.com/MarvinGeng/archive/2012/07/19/2598625.html原创 2016-06-16 21:15:30 · 285 阅读 · 0 评论 -
c++正则表达式
#include void GetValueFromFilesName(std::string s, float &x, float &z, float &angle) { std::vector str; std::smatch sm; s.erase(s.size() - 4, s.size() - 1); std::regex re("[-0-9.]+[0-9]+[0-9]"原创 2018-01-19 17:50:04 · 181 阅读 · 0 评论