随笔分类 -  c++

c清除输入缓冲
摘要:// 三种方法: fflush(stdin); // 不靠谱 setbuf(stdin, NULL); // gcc 可用 scanf("%*[^\n]%*c"); // %*表示丢弃这些字符 阅读全文

posted @ 2018-03-05 21:28 photonCarry 阅读(148) 评论(0) 推荐(0)

多态时要注意不要拉了const,否则多态无效
摘要:多态时除了virtual还要注意不要忘了了const,否则多态无效 阅读全文

posted @ 2016-03-17 22:36 photonCarry 阅读(379) 评论(0) 推荐(0)

VS中 DLL的创建及函数导出(参考MSDN)
摘要:新建一个DLL工程: 新建 - 项目 - vc++ - win32 - win32控制台应用程序,工程名假设取为MathFuncsDll 向导中选择DLL,取消预编译头完成。此时会有dllmain.cpp, MathFuncsDll.cpp 两个cpp文件及生成的 stdafx.h, targe... 阅读全文

posted @ 2015-12-31 14:18 photonCarry 阅读(2841) 评论(0) 推荐(0)

基于MFC的OPENCV程序的静态编译
摘要:若在创建MFC程序时没有选择在静态库中使用MFC也没有关系。在工程属性-常规-中设置 将在共享DLL中使用MFC改为静态。 接下来到c++选项-代码生成 页面,将运行库/MD (/MDd)改为/MT(/MTd对应debug版本,既然要发布,也没必要用debug版本吧),更改了这两个设置,重新... 阅读全文

posted @ 2015-12-24 15:06 photonCarry 阅读(1387) 评论(0) 推荐(0)

cout控制输出
摘要:cout using std::setw;using std::setfill;头文件#include 不能忘 阅读全文

posted @ 2015-06-14 18:51 photonCarry 阅读(166) 评论(0) 推荐(0)

控制输出换行
摘要:1 //output result2 os << " " << "Result:" << " | ";3 for(int i = 0; i < 5; i++) {4 os << res[i] << ((4-i)?" ":"\n");5 }<<运算符比 ?运算符优先级要高的。要注意使用。 阅读全文

posted @ 2015-06-14 18:01 photonCarry 阅读(175) 评论(0) 推荐(0)

导航