
C++
C++总结
墨理学AI
计算机视觉领域,新晋砖家 ☞
未来可期,欢迎和墨理一起学 AI 》 博主创建了很多CV领域的技术Club,欢迎主页左侧下方,Contact my WeChat;
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Linux下Segmentation fault (core dumped) 段错误的处理方法 | 个人笔记
Segmentation fault (core dumped) 段错误的处理方法说一个真实的感受,接手一个C++项目,运行着莫名就 出来一个 段错误,作为小白玩家,一脸懵逼,还有些许慌张;听大佬同事一顿教诲,终究是自己慢慢查阅代码、printf 抗下了所有比较常规(实用)的小白操作:就是 printf("-------------") ,嗯,不断地在关键 代码位置前后打印日志使用gdb进行C-C++程序调试Linux下使用gdb进行C-C++程序调试第一讲...原创 2021-05-14 10:23:55 · 677 阅读 · 0 评论 -
预处理(Preprocessing)、编译(Compilation)、汇编(Assembly)和链接(Linking)| 个人笔记
预处理(Preprocessing)、编译(Compilation)、汇编(Assembly)和链接(Linking)hello.c 相关代码#include <stdio.h>int main(){ printf("Hello World\n"); return 0;}运行效果如下 – 尊重原创 追加 原文链接于此 ...原创 2021-05-13 18:23:26 · 431 阅读 · 0 评论 -
cmake CMakeLists.txt 的编写和基础使用
cmake CMakeLists.txt 的编写和基础使用hello.cpp 和 CMakeLists.txt 的简洁编写同一目录下 依次编写 hello.cpp 和 CMakeLists.txtCMakeLists.txt 是 cmake 的构建定义文件vim hello.cpp#include<stdio.h>void printHello(){ printf("hello moli \n");}int main(){ printHello().原创 2021-04-27 16:59:06 · 740 阅读 · 0 评论 -
c++ list, vector, map, set 区 别 | 示例代码
c++ list, vector, map, set 区 别参考 – 博文 List封装了链表,Vector封装了数组, list和vector得最主要的区别在于vector使用连续内存存储的,他支持[]运算符,而list是以链表形式实现的,不支持[]。Vector对于随机访问的速度很快,但是对于插入尤其是在头部插入元素速度很慢,在尾部插入速度很快。List对于随机访问速度慢得多,因为可能要遍历整个链表才能做到,但是对于插入就快的多了,不需要拷贝和移动数据,只需要改变指针的指向就可以了。.原创 2021-04-07 16:56:57 · 227 阅读 · 0 评论 -
C++ 11 map 遍历 | 代码简记
C++ 11 map 遍历输出示例如下:代码如下// 两种类型 map 示例#include <iostream>#include <map>#include <string>int main(){ std::map<char, std::string> mymap; mymap['a'] = "an element"; mymap['b'] = "another element"; mymap['.原创 2021-04-06 20:39:26 · 2480 阅读 · 0 评论 -
C++11 auto类型推导 | 示例代码优缺点分析
认识 autoauto 的应用确实是一个蛮不错的C++教程原教程链接 – http://c.biancheng.net/view/6984.html原创 2021-04-06 20:01:34 · 449 阅读 · 0 评论 -
C++ 之 for 循环 | C++11 for 循环 | 内存 Destory 示例
这C++ 之 传统 for 循环 和 C++11 for 循环#include <iostream>int main(){ int arr[4] = {100, 200, 300, 400}; std::cout << "传统 for 循环如下" << std::endl; std::cout << "___________________" << std::endl; for (int i = 0.原创 2021-04-06 19:14:31 · 363 阅读 · 0 评论 -
VSCode C++ 代码断点调试示例
win10 最新 Visual Studio Code C++ 运行配置 – 教程纸糊 – 大佬 – 小白友好型 – windows 10上使用vscode编译运行和调试C/C++VSCode C++ 代码 进行 调试 示例 方式 如下:本博文示例代码#include <iostream>using namespace std;int main(){ // cout << "Hello World!" << endl; int i = 0.原创 2021-04-06 16:34:57 · 3987 阅读 · 5 评论 -
C++获取当前时间(北京时间)
C++获取当前时间#include <iostream>#include <ctime> using namespace std; int main( ){ time_t now = time(0); cout << "1970 到目前经过秒数:" << now << endl; tm *ltm = localtime(&now); cout << "年: "<<.原创 2021-03-16 17:32:33 · 4074 阅读 · 1 评论 -
C++类对象和实例创建
类只是一个模板(Template),编译后不占用内存空间,所以在定义类时不能对成员变量进行初始化,因为没有地方存储数据。只有在创建对象以后才会给成员变量分配内存,这个时候就可以赋值了。#include <iostream>#include <stdlib.h>using namespace std;class Solution{public: int age; char *name; string like; int dump(int number){ .原创 2021-03-12 14:20:25 · 1012 阅读 · 0 评论 -
C++ 编程练习题目(青蛙跳台阶)
C++ 编程练习题目(第一个月)青蛙跳台阶–递归代码(循环)class Solution {public: int jumpFloor(int number) { if (number <= 0) { return 0; } if (number <= 2){ return number; } int first = 1, second =.原创 2021-03-11 20:43:53 · 580 阅读 · 0 评论 -
main.cpp:(.text+0xd06): undefined reference to xx 方法 | 简单记录
该博文只是一个C++编译安装问题记录–没有给出正确解决方法main.cpp:(.text+0xd06): undefined reference to `uni_text::UniText::UniText(std::string const&, int)'main.cpp:(.text+0xe73): undefined reference to `uni_text::UniText::PutText(cv::Mat&, std::string const&, cv::Po.原创 2021-03-09 17:15:40 · 2045 阅读 · 0 评论 -
第三方依赖库 freetype 的安装
下载链接:https://download.savannah.gnu.org/releases/freetype/tar xf freetype-2.10.2.tar.xz cd freetype-2.10.2./configuremakemake install原创 2021-03-09 16:00:15 · 1068 阅读 · 0 评论 -
error: ‘ceil‘ is not a member of ‘std‘ | error: ‘floor‘ is not a member of ‘std‘
error: 'ceil' is not a member of 'std'或者 error: 'floor' is not a member of 'std'解决方法,添加对应头文件#include <math.h>上面的有时候不好用#include <cmath>原创 2021-03-09 15:54:11 · 2275 阅读 · 0 评论 -
error: ‘shared_ptr‘ in namespace ‘std‘ does not name a type
make install 安装时编译代码遇到的错误:warning: non-static data member initializers only available with -std=c++11 or -std=gnu++11 [enabled by default] float confidence = 0;error: 'shared_ptr' in namespace 'std' does not name a type解决方法:这是因为要使用C+.原创 2021-03-09 15:48:43 · 2911 阅读 · 1 评论 -
win10 最新 Visual Studio Code C++ 运行配置——代码保存 格式自动调整
window10 操作系统Visual Studio Code | C++代码保存 格式自动调整 |新建 .clang-format 配置文件,代码风格设置内容如下:---AccessModifierOffset: -1AlignAfterOpenBracket: AlwaysBreakAlignConsecutiveAssignments: falseAlignConsecutiveDeclarations: falseAlignEscapedNewlinesLeft: trueA.原创 2021-02-26 20:05:12 · 1703 阅读 · 0 评论 -
C++ int 类型转 string | C++11 std::to_string
使用 std::to_string 方法,需要 C++11 以上支持示例代码如下:#include <string>#include <iostream>#include <vector> #include <fstream> #include <string.h>#include <dirent.h>using namespace std;int main(){ int i = 10; string原创 2021-02-23 11:54:22 · 1172 阅读 · 0 评论 -
Linux下C 安装 指定 make install 或者 pip install安装路径、pip install . 和 pip install -e . 区别
参考链接在Linux下直接用pip install packageName 或者 make install ,有些文件会被放到根目录下,如果没有sudo权限的话,是会安装失败的。因此需要指定安装的目录了。pip install 指定安装目录pip install -t /opt/anaconda3/lib/python3.6/site-packages scedarmake i...原创 2019-03-01 19:44:20 · 2846 阅读 · 0 评论 -
C++ main 方法传递参数
示例代码如下:#include <iostream>using namespace std; int main(int argc, char * argv[]){//如果你需要2个参数,这里就 与 3 做判断,可自行尝试 if (argc != 3) { cout<<"You should use only two arguments!"<<...原创 2018-11-24 13:32:39 · 3513 阅读 · 0 评论 -
C++使用空格或者特定字符 分割字符串string
请看代码示例, 复制粘贴,运行即可,使用其他字符做分割,则 用该 字符 替换 strtok 函数 第二个参数 即可// strings and c-strings#include <iostream>#include <cstring>#include <string>using namespace std;int main (){ std:...原创 2018-11-24 13:09:01 · 20848 阅读 · 1 评论 -
C++遍历文件夹下所有的wav文件(支持windows和Linux)
直接上代码:#include &amp;amp;amp;lt;iostream&amp;amp;amp;gt; #include &amp;amp;amp;lt;string&amp;amp;amp;gt; #include &amp;amp;amp;lt;vector&amp;amp;amp;gt; #include &amp;amp;amp;lt;fstream&原创 2018-11-16 11:53:19 · 871 阅读 · 0 评论 -
C++获得毫秒级的时间差(支持Windows 和 Linux)
fatal error: windows.h: No such file or directory我这里Windows 里面引用了 #include &amp;amp;lt;windows.h&amp;amp;gt; ,使用下面的方法测量函数运行时间 #include &amp;amp;lt;windows.h&amp;amp;gt; long start_time = GetTickCount(); test(原创 2018-11-16 11:18:19 · 7988 阅读 · 0 评论 -
Linux 下 C++ 环境搭建 | gcc安装
Linux 下 C++ 环境安装;Ubuntu 下安装:sudo apt-get install openssh-server g++ gdb gdbserver原创 2018-11-14 15:08:12 · 1466 阅读 · 0 评论 -
Linux 部署C++音频读取方法代码遇到的问题:
原文链接:No such file or directory #include &amp;amp;amp;amp;amp;amp;amp;amp;lt;io.h&amp;amp;amp;amp;amp;amp;amp;amp;gt;用命令查找io.h所在位置:find /usr/include -name “io.h”,结果发现在/usr/include下没有,但在/usr/include/x86_64-linux-gnu/sys下有用命令把io.h复制到/u原创 2018-11-13 14:08:35 · 1749 阅读 · 0 评论 -
C++ 除法 四舍五入
代码:#include<iostream>#include <cmath>using namespace std;int main(){ long size = 101; cout<< size / 2<<endl; cout<<ceil(10.5) <<endl; cout<<cei原创 2018-11-07 10:56:17 · 4583 阅读 · 2 评论 -
如何在windows下使用c++11标准 (Dev C++切换 C++ 11 环境)
安装之后需要简单设置一下。设置方法:Tools - Compiler Options - Settings - Code GenerationLauguage standaerd(-std)选项下拉菜单中选择 GNU C++11Dev-Cpp 5.4.2下载地址:...原创 2018-11-09 17:44:57 · 4969 阅读 · 0 评论 -
C++ char、string、int、float 相互【类型转换】
直接上代码,编译运行,跟着结果对比就好理解#include<iostream>#include<string>#include<sstream>#include<cstring>#include <stdlib.h>#include <stdio.h>using namespace std;int main(...原创 2018-11-25 19:21:38 · 1485 阅读 · 0 评论 -
Windows环境下的安装gcc | c++配置
参考链接一参考链接二————可以配置环境到sublime进行C++开发非常感谢两位原作者!转载 2018-11-29 11:40:38 · 1418 阅读 · 0 评论 -
C++优化过程简单笔记
信噪比计算优化过程记录(第一份C++代码的优化记录)工作内容介绍:SNR计算Matlab代码转C++运行环境:i7 四代Windows 10系统8G 内存数据:100 条 音频,总大小 19.5 M ,平均每个音频 大小为 200 kbMatlab 代码运行时间为:13.463308s第一版C++运行时间为:14375 ms优化过程:优化1:弃用pu...原创 2019-02-02 11:22:04 · 377 阅读 · 0 评论 -
fstream 中判断是否成功打开文件 | C++中文件流(fstream)的使用方法及示例
ifstream fin("filename");if (!fin){ cout << "fail to open the file" <<endl; return -1;//或者抛出异常。}else{ cout << "open the file successfully" << endl;}文件流参考链接转载 2018-11-29 17:51:53 · 4014 阅读 · 0 评论 -
C++使用system pause 来暂停黑窗口
system(“Pause”)表示直接调用DOS命令Pause。说明:void system(char *cmd);参数cmd,DOS命令,如Pause, cls返回值:无代码如下:#include <stdio.h> #include <stdlib.h> int main() { system("Pause"); return 0; }...原创 2018-11-29 17:57:02 · 4594 阅读 · 0 评论 -
fstream 中判断是否成功打开文件 | C++中文件流(fstream)的使用方法及示例
ifstream fin("filename");if (!fin){ cout << "fail to open the file" <<endl; return -1;//或者抛出异常。}else{ cout << "open the file successfully" << endl;}文件流参考链接转载 2018-11-29 13:59:56 · 4272 阅读 · 2 评论 -
C/C++整数除法以及保留小数位的问题 | 设置输出宽度 | 设置左对齐
原文链接,非常感谢原作#include <iostream> #include <iomanip>using namespace std; int main(){ int a,b; cin>>a>>b; int C = a / b; cout<<C<<endl; double e = a, f = b...原创 2018-11-29 13:43:06 · 9921 阅读 · 0 评论