随笔分类 -  C++

C++中报错——“min”:未声明的标识符
摘要:环境:VS2017问题:编译提示“min,找不到标识符 解决方案:添加代码 #include <algorithm> 转发:https://blog.csdn.net/qq_39141406/article/details/90511661 阅读全文

posted @ 2024-11-10 18:39 Livid 阅读(199) 评论(0) 推荐(0)

【C语言】解决error C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead...
摘要:几天编译文件的时候报错, 编译出错信息:错误 1 error C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _C 阅读全文

posted @ 2024-11-10 17:39 Livid 阅读(978) 评论(0) 推荐(0)

(转)c++ std::pair 与 std::make
摘要:转自http://code.jiaosha.org/question.aspx?url=wince159___79144d1723769b40f3de32cb.html std::pair主要的作用是将两个数据组合成一个数据,两个数据可以是同一类型或者不同类型。例如std::pair 或者 std::pair等。pair实质上是一个结构体,其主要的两个成员变量是first和second,这两个变量可以直接使用。初始化一个pair可以使用构造函数,也可以使用std::make_pair函数,make_pair函数的定义如下:template pair make_pair(t1 a, t2 b) 阅读全文

posted @ 2011-11-22 10:24 Livid 阅读(1090) 评论(0) 推荐(0)

读取文件中数据,并赋值给二维数组
摘要:void main(){int row, col;cout << "Please enter the number for row and column: " << endl;cin >> row >>col;//为二维数组开辟空间int **Result = new int*[row];for (int i = 0; i < row; i++){Result[i] = new int[col];}ifstream fin("./data.txt");for (int i = 0; i != row; 阅读全文

posted @ 2011-10-30 09:41 Livid 阅读(544) 评论(0) 推荐(0)

牛顿迭代法
摘要:用牛顿迭代法求f(x)=0在x0附近的一个实根的方法是:(1) 选一个接近于x的真实根的近似根x1;(2) 通过x1求出f(x1)。在几何上就是作x=x1,交f(x)于f(x1); (3) 过f(x1)作f(x)的切线,交x轴于x2。可以用公式求出x2。由于f'(x1)=f(x1)/(x2-x1),故x2=x1-f(x1)/f'(x1) (4) 通过x2求出f(x2);(5) 再过f(x2)作f(x)的切线交x轴于x2;(6) 再通过x3求出f(x3),…一直求下去,直到接近真正的根。当两次求出的根之差|xn+1-xn|≤ε就认为 xn+1足够接近于真实根。 牛顿迭代公式是:x 阅读全文

posted @ 2011-05-20 22:43 Livid 阅读(1032) 评论(0) 推荐(0)

预编译头文件来自编译器的早期版本,或者预编译头为 C++ 而在 C 中使用它(或相反)
摘要:当 Visual C++ 项目启用了预编译头 (Precompiled header) 功能时,如果项目中同时混合有 .c 和 .cpp 源文件,则可能收到 C1853 编译器错误:fatal error C1853: 'pjtname.pch' precompiled header file is from a previous version of the compiler, or the precompiled header is C++ and you are using it from C (or vice versa)(致命错误C1853: “filename.pc 阅读全文

posted @ 2011-04-18 20:39 Livid 阅读(21401) 评论(2) 推荐(3)

C++ vector 类学习笔记(转)
摘要:作者: tyc611, 2007-01-15 发表于: http://blog.chinaunix.net/u/18517/showart_232126.htmlvector容器类型 vector容器是一个模板类,可以存放任何类型的对象(但必须是同一类对象)。vector对象可以在运行时高效地添加元素,并且vector中元素是连续存储的。vector的构造函数原型:template<typename T> explicit vector(); // 默认构造函数,vector对象为空 explicit vector(size_type n, const T& v = T() 阅读全文

posted @ 2011-04-10 00:31 Livid 阅读(534) 评论(0) 推荐(0)

C++ string类的一些函数方法(转)
摘要:string类的构造函数:string(const char *s); //用c字符串s初始化string(int n,char c); //用n个字符c初始化此外,string类还支持默认构造函数和复制构造函数,如string s1;string s2="hello";都是正确的写法。当构造的string太长而无法表达时会抛出length_error异常 string类的字符操作:const char &operator[](int n)const;const char &at(int n)const;char &operator[](int n) 阅读全文

posted @ 2011-04-10 00:30 Livid 阅读(1004) 评论(0) 推荐(0)

c++ map的使用方法(转自http://www.cnblogs.com/JCSU/articles/1996876.html)
摘要:/**************************************************************************Map的特点:1、存储Key-value对*2、支持快速查找,查找的复杂度基本是Log(N)*3、快速插入,快速删除,快速修改记*/************************************************************************/#include<stdio.h>#pragmawarning(disable:4786)#include<string>#include<m 阅读全文

posted @ 2011-04-10 00:26 Livid 阅读(3667) 评论(0) 推荐(0)

C++动态数组分配
摘要:动态一维数组:#include<iostream>using namespace std;int main(){ int len; cin>>len; int *p=new int[len]; delete[] p; p = NULL; return 0;}动态二维数组:int main(){ int row, col; cout << "Please enter the number for row and column: " << endl; cin >> row >>col; //为二维数组开辟空 阅读全文

posted @ 2011-04-01 15:06 Livid 阅读(353) 评论(0) 推荐(0)

内存泄漏检测工具(转载)
摘要:内存泄漏检测工具2007年08月08日1. ccmalloc-Linux和Solaris下对C和C++程序的简单的使用内存泄漏和malloc调试库。 2. Dmalloc-Debug Malloc Library. 3. Electric Fence-Linux分发版中由Bruce Perens编写的malloc()调试库。 4. Leaky-Linux下检测内存泄漏的程序。 5. LeakTracer-Linux、Solaris和HP-UX下跟踪和分析C++程序中的内存泄漏。 6. MEMWATCH-由Johan Lindh编写,是一个开放源代码C语言内存错误检测工具,主要是通过gcc的pr 阅读全文

posted @ 2011-04-01 11:39 Livid 阅读(271) 评论(0) 推荐(0)

(转)Computer Vision Open Source Algorithm Implementations
摘要:Computer Vision Open Source Algorithm ImplementationsParticipate in Reproducible ResearchWARNING: this page is not and will never be exhaustive but only try to gather robust implementations of Computer Vision state of the art(back to computer vision resource)If you have additions or changes, send an 阅读全文

posted @ 2011-03-31 11:31 Livid 阅读(1480) 评论(0) 推荐(1)

VC获取一个菜单的状态,并打钩
摘要:void CMainFrame::OnShowStandToolbar() //设置菜单状态{ if (AfxGetMainWnd()->GetMenu()->GetMenuState(ID_STANDTOOLBAR,MF_CHECKED)){AfxGetMainWnd()->GetMenu()->CheckMenuItem(ID_STANDTOOLBAR,MF_UNCHECKED);}else{AfxGetMainWnd()->GetMenu()->CheckMenuItem(ID_STANDTOOLBAR,MF_CHECKED);}} 阅读全文

posted @ 2011-03-26 11:27 Livid 阅读(722) 评论(0) 推荐(0)

fatal error CVT1100: duplicate resource. type:MANIFEST, name:1, language:0×0409
摘要:从vc6和vc7的工程迁移到vc8上的时候,遇到了这么个错误:CVTRES : fatal error CVT1100: duplicate resource. type:MANIFEST, name:1, language:0×0409LINK : fatal error LNK1123: failure during conversion to COFF: file invalid or corrupt搜了一下,有人说可以用这样的方法解决: “将linker里的manifest File的generate manifest选项设置为no即可,也不用去修改manifest文件了”但 阅读全文

posted @ 2011-03-24 11:19 Livid 阅读(2017) 评论(0) 推荐(0)

转:vc2005下的clapack...吐血之作
摘要:费了一整天,研究vc2005下的clapack。。各种错误,各种尝试。最后明白,不放弃是王道!参考了Kaien 和Kevin Wong。做了些改动,要不然不好使啊。。////////////////////以下初始工作///////////////////////////我的配置:VS2005 和 CLAPACK版本: 3.1.1下载解压后,我们可以看到如下目录结构:\SRC CLAPACK的源代码\BLAS BLAS的源代码\F2CLIBS F2C的源代码\LIB 编译后的库文件.lib\INCLUDE 头文件\TESTING 一些使用范例程序\INSTALL 里面有UNIX和其他平台下安装 阅读全文

posted @ 2011-03-12 20:24 Livid 阅读(904) 评论(0) 推荐(1)

转:error LNK2005
摘要:今天一大早,VC就给我来了个下马威,昨天还老老实实工作着的程序,竟然出现58个错误,而且还都是类似的LNK2005!满满的一屏error,这对于初为程序员的我,那简直是致命的,心灵受的打击啊~~~ 赶紧Google,发现各位程友们也被这困扰着,不过还是有高手支招的,以下摘录:编程中经常能遇到LNK2005错误——重复定义错误,其实LNK2005错误并不是一个很难解决的错误。弄清楚它形成的原因,就可以轻松解决它了。造成LNK2005错误主要有以下几种情况: 1.重复定义全局变量。可能存在两种情况: A、对于一些初学编程的程序员,有时候会以为需要使用全局变量的地方就可以使用定义申明一下。其实这是. 阅读全文

posted @ 2011-03-12 20:23 Livid 阅读(1204) 评论(0) 推荐(1)

模板函数min/max与Visual C++中的 min/max宏冲突
摘要:本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/zhuangshn/archive/2010/04/28/5537499.aspx1. 错误输出 .\zlibrary\ui\src\win32\w32widgets\W32VBorderBox.cpp(114) : error C2589: “(”: “::”右边的非法标记 .\zlibrary\ui\src\win32\w32widgets\W32VBorderBox.cpp(114) : error C2059: 语法错误 : “::”2. 错误代码举例 view plaincopy to clipboard 阅读全文

posted @ 2011-03-12 16:56 Livid 阅读(1389) 评论(0) 推荐(0)

C++ string类常用函数
摘要:【转】C++ string类常用函数http://xiaocao000.spaces.live.com/blog/cns!F826A925CF33491A!117.entrystring类的构造函数:string(const char *s); //用c字符串s初始化string(int n,char c); //用n个字符c初始化此外,string类还支持默认构造函数和复制构造函数,如string s1;string s2="hello";都是正确的写法。当构造的string太长而无法表达时会抛出length_error异常 string类的字符操作:const char 阅读全文

posted @ 2011-03-11 16:42 Livid 阅读(256) 评论(0) 推荐(0)

msvcr80d.dll–处未处理的异常: 0xC0000005
摘要:转自:http://www.dakaren.com/index.php/archives/358.htm/page/3/本人出现的中断错误:AudioManager.exe 中的 0x657ac2b2 (msvcr80d.dll) 处未处理的异常: 0xC0000005: 读取位置 0xccccccc8 时发生访问冲突网上类似的帖子介绍:开发环境 VS2005 + MFC基于对话框的工程BOOL CVideoMFCApp::InitInstance(){ // 如果一个运行在 Windows XP 上的应用程序清单指定要 // 使用 ComCtl32.dll 版本 6 或更高版本来启用可视化方 阅读全文

posted @ 2010-12-24 23:08 Livid 阅读(2932) 评论(0) 推荐(0)

关于项目依赖项
摘要:在生成解决方案时,可能需要首先生成某些项目,以便生成由其他项目使用的可执行代码。使用 “解决方案属性页”对话框 ->“通用属性”->“项目依赖项” 设置当前生成顺序。若要访问此对话框,请在“解决方案资源管理器”中选择一个解决方案,选择“视图”菜单上的“属性... 阅读全文

posted @ 2010-11-23 20:07 Livid 阅读(2263) 评论(0) 推荐(0)

导航