![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
C/C++
文章平均质量分 59
Hi_Panda_CRL
这个作者很懒,什么都没留下…
展开
-
c++中new和delete的使用方法
c++中new和delete的使用方法new和delete运算符用于动态分配和撤销内存的运算符new用法: 1. 开辟单变量地址空间 1)new int; //开辟一个存放数组的存储空间,返回一个指向该存储空间的地址.int *a = new int 即为将一个int类型的地址赋值给整型指针a.转载 2012-08-14 12:50:12 · 504 阅读 · 0 评论 -
函数与array对象
#include "stdafx.h"#include#include#includeusing namespace std;const int Seasons = 4; //使用Seasons来替换数字4const arraySnames = {"Spring", "Summer", "Fall", "Winter"};//使用了一个const array对象,该对象包含4个s原创 2015-04-30 16:49:32 · 512 阅读 · 0 评论 -
函数和数组
//函数和数组#include "stdafx.h"#includeconst int ArSize = 8;int sum_arr(int arr[], int n);//定义函数数组int main(){ using namespace std; int cookies[ArSize] = {1,2,4,8,16,32,64,128}; int sum = sum_ar原创 2015-04-27 09:41:52 · 535 阅读 · 0 评论 -
指针和const
指针和const将const用于指针有一些微妙的地方:第一种:让指针指向一个常量对象。这样可以防止使用指针来修改所指向的值;第二种:将指针本身声明为常量,这样可以防止改变指针指向的位置;原创 2015-04-30 09:30:13 · 430 阅读 · 0 评论 -
*p,p和&p区别:
//*p,p和&p区别:#include int main(void){ int a=20; int *q; //定义一个整型的指针变量q q=&a; //将变量a的地址放在指针变量q中 printf("变量a的地址为: %p\n",&a转载 2015-05-13 16:21:10 · 3160 阅读 · 0 评论 -
构造函数与成员函数的区别?
构造函数是一种特殊的方法主要用来在创建对象时初始化对象即为对象成员变量赋初始值总与new运算符一起使用在创建对象的语句中 特别的一个类可以有多个构造函数 可根据其参数个数的不同或参数类型的不同来区分它们 即构造函数的重载 构造函数与其他方法的区别:1.构造函数的命名必须和类名完全相同;而一般方法则不能和类名相同.2.构造函数的功能主要用于在类的对象创建转载 2015-05-15 10:53:56 · 10141 阅读 · 0 评论 -
函数指针
#include "stdafx.h"#include double betsy(int);double pam(int);int main(){ using namespace std; int code; cout<<"how mann lines of code do you need? "; cin>>code; cout<<"here's betsy's esti原创 2015-05-13 16:57:15 · 461 阅读 · 0 评论 -
C++常见问题
1、建立Win32 Console Project/MFC项目时会出现"LINK : fatal error LNK1123: 转换到 COFF 期间失败: 文件无效或损坏"的错误。错误描述:1>正在编译资源...1>正在编译资源清单...1>正在链接...1>LINK : fatal error LNK1123: 转换到 COFF 期间失败: 文件无效或损坏1原创 2014-09-17 15:19:10 · 618 阅读 · 0 评论 -
C++中的类
// stock00.h -- Stock class interface// version 00#ifndef STOCK00_H_#define STOCK00_H_#include class Stock // class declaration{private: std::string company; long shares; doub原创 2015-05-14 15:26:10 · 582 阅读 · 0 评论 -
文件的输入和输出
#include //首先需要包含头文件fstream#include#include int main(){ using namespace std; string filename; cout<<"Enter name for new file: "; cin >> filename; //声明一个名称为fout的ofstream对象 ofstream fout(fi原创 2015-05-25 09:42:36 · 640 阅读 · 0 评论 -
类模板---双向链表
#ifndef DOUBLY_LINKED_LIST#define DOUBLY_LINKED_LISTtemplateclass DLLNode{public: DLLNode(){ next = prev = 0; } DLLNode(const T& el, DLLNode *n = 0, DLLNode *p = 0){ info = el; next = n原创 2015-12-12 10:51:05 · 659 阅读 · 0 评论 -
单链表
#ifndef INT_LINKED_LIST#define INT_LINKED_LIST//for nodes of the listclass IntSLLNode{public: //all members of IntSLLNode are declared public,in order to accessible through pointers, IntSLLNod原创 2015-12-12 11:08:02 · 486 阅读 · 0 评论 -
VS CONFIG
Debug Win32 Release Win32 {73425F56-B0B2-432D-B097-5BF00F67CFCB} Win32Proj test1 hough Application true Unicode Ap原创 2015-12-28 11:27:50 · 784 阅读 · 0 评论 -
堆栈练习
1、Vector实现#ifndef STACK#define STACK#include templateclass Stack{public: Stack(){ pool.reserve(capacity); } //清空 void clear(){ pool.clear(); } //判断堆栈是否为空 bool isEmpty() const{原创 2015-12-20 20:38:39 · 708 阅读 · 0 评论 -
队列练习
1、数组实现#ifndef ARRAY_QUEUE#define ARRAY_QUEUEtemplateclass ArrayQueue{public: ArrayQueue(){ first = last =-1; } void enqueue(T); T dequeue(); bool isFull() { //first在前 || last在first之前原创 2015-12-20 20:45:30 · 532 阅读 · 0 评论 -
获取编译时间
double t = (double)getTickCount(); t = (double)getTickCount() - t; printf("tdetection time = %gms\n", t*1000./cv::getTickFrequency());原创 2015-12-05 19:06:45 · 1162 阅读 · 0 评论 -
C++文件操作
#include "stdafx.h"#include#includeint main(){ using namespace std; char automobile[50]; int year; double a_price; double d_price; ifstream inFile; inFile.open("a.txt"); if (!inFile原创 2015-04-24 10:15:49 · 393 阅读 · 0 评论 -
typedef与define的区别
1) #define是预处理指令,在编译预处理时进行简单的替换,不作正确性检查,不关含义是否正确照样带入,只有在编译已被展开的源程序时才会发现可能的错误并报错。例如:#define PI 3.1415926程序中的:area=PI*r*r 会替换为3.1415926*r*r如果你把#define语句中的数字9 写成字母g 预处理也照样带入。2)typedef是在编译时处理的转载 2015-04-16 15:15:19 · 375 阅读 · 0 评论 -
类型组合(数组、指针)
#include "stdafx.h"#include#include//构造结构struct antarctica_year_end{ int year;};int main(){ //类型组合 using namespace std;; antarctica_year_end s01, s02, s03; //创建类型变量 s01.year = 1998;原创 2015-04-16 13:17:35 · 670 阅读 · 0 评论 -
MFC 多线程编程
MFC 多线程编程一、问题的提出编写一个耗时的单线程程序: 新建一个基于对话框的应用程序SingleThread,在主对话框IDD_SINGLETHREAD_DIALOG添加一个按钮,ID为IDC_SLEEP_SIX_SECOND,标题为“延时6秒”,添加按钮的响应函数,代码如下:void CSingleThreadDlg::OnSleepSixSecond() {转载 2012-08-14 15:41:07 · 996 阅读 · 0 评论 -
C++内存分配秘籍—new,malloc,GlobalAlloc详解
C++内存分配秘籍—new,malloc,GlobalAlloc详解 C++内存分配秘籍—new,malloc,GlobalAlloc详解 _______只为因内存分配而无法入眠的程序员一。关于内存 1、内存分配方式 内转载 2012-08-14 13:28:17 · 740 阅读 · 0 评论 -
Visual Studio调试多线程应用程序
Visual Studio调试多线程应用程序10.3.3 调试多线程应用程序多线程应用程序是在给定的进程中有多于一个的线程在运行的应用程序。默认情况下,每个运行应用程序的进程有至少一个执行线程。你也许创建多个线程来做并行处理。这可以显著地提升性能,尤其在运行今天的多核处理器和超线程技术的时候。然而,多线程也带来了更大的开销。代码变得更加复杂难写且更难于调试。如果你曾写过多线程应用程序,转载 2012-08-14 15:53:29 · 4482 阅读 · 0 评论 -
明晰C++内存分配的五种方法的区别
在C++中,内存分成5个区,他们分别是堆、栈、自由存储区、全局/静态存储区和常量存储区。 栈,就是那些由编译器在需要的时候分配,在不需要的时候自动清楚的变量的存储区。里面的变量通常是局部变量、函数参数等。 堆,就是那些由new分配的内存块,他们的释放编译器不去管,由我们的应用程序去控制,一般一个new就要对应一个delete。如果程序员没有释放掉,那么在程序结束后,操作系统转载 2012-08-14 12:11:55 · 488 阅读 · 0 评论 -
ANSI, GB2132, Unicode, UTF-8介绍
ANSI 的"Ascii"编码使用了单字节的1~127值。 汉字是使用0xA1到0xFE之间的值,二个字节表示一个汉字。一共可显示汉字个数为(0XFE - 0XA1) * (0XFE - 0XA1) = 8649 。如果默认非Uncoide的编码是中文简体,即使用GB2132编码。一个英文字符用一个字节,一个汉字用两个字节。(即在非Uncoide程序中,我们对字转载 2012-08-14 17:55:54 · 1162 阅读 · 0 评论 -
Unicode与UTF-8/UTF-16/UTF-32的区别
Unicode的最初目标,是用1个16位的编码来为超过65000字符提供映射。但这还不够,它不能覆盖全部历史上的文字,也不能解决传输的问题 (implantation head-ache's),尤其在那些基于网络的应用中。已有的软件必须做大量的工作来程序16位的数据。 因此,Unicode用一些基本的保留字符制定了三套编码方式。它们分别是UTF-8,UTF-16和UTF-32。正如名字转载 2012-08-15 10:18:20 · 2168 阅读 · 0 评论 -
使用 Unicode 编码
.NET Framework 2.0面向公共语言运行库的应用程序使用编码将字符表示形式从本机字符方案(Unicode)映射为其他方案。应用程序使用解码将字符从非本机方案(非 Unicode)映射为本机方案。System.Text 命名空间提供了使您能够对字符进行编码和解码的类。System.Text 编码支持包括以下编码:Unicode UTF-32 编码Unico转载 2012-08-15 10:47:37 · 782 阅读 · 0 评论 -
string, char*, int类型转换 , c++强制转化
以下是常用的几种类型互相之间的转换string 转 int..............................char* 转 int #include int atoi(const char *nptr); long atol(const char *nptr); long long atoll(const char *nptr); long long atoq(con原创 2012-08-15 16:24:04 · 3662 阅读 · 0 评论 -
C#调用SQL Server存储过程简单实例
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.Dat转载 2013-07-09 15:13:10 · 1040 阅读 · 0 评论 -
C++ ofstream和ifstream详细用法以及C语言的file用法
ofstream是从内存到硬盘,ifstream是从硬盘到内存,其实所谓的流缓冲就是内存空间; 在C++中,有一个stream这个类,所有的I/O都以这个“流”类为基础的,包括我们要认识的文件I/O,stream这个类有两个重要的运算符: 1、插入器( 向流输出数据。比如说系统有一个默认的标准输出流(cout),一般情况下就是指的显示器,所以,cout 2、转载 2014-09-05 17:02:21 · 1957 阅读 · 0 评论 -
C++遍历
#include #include #includeusing namespace std;const int MAXLEN = 1024; //定义最大目录长度 unsigned long FILECOUNT = 0; //记录文件数量 void ListDir(const char* pc转载 2014-08-26 23:01:03 · 595 阅读 · 0 评论 -
BAT清理IE缓存和系统垃圾
@echo off echo 清空IE临时文件目录...del /f /s /q "%userprofile%\AppData\Local\Microsoft\Windows\Temporary Internet Files\*.*"clsecho.echo 清理IE缓存完毕,是否清理系统缓存?echo.echo 是请按任意键继续,否则请直接关闭本窗口。pause>nuld转载 2014-09-03 13:17:11 · 6096 阅读 · 0 评论 -
结构声明
#include "stdafx.h"#includestruct inflatable{ char name[20]; float volume; double price;};int main(){ using namespace std; inflatable guest={ "Glorious Gloria", 1.88, 29.99 }; i原创 2015-04-14 08:24:20 · 478 阅读 · 0 评论 -
数组的替代品VECTOR
#include "stdafx.h"#include#include#includeint main(){ using namespace std; double a1[4] = {1.2, 2.4, 3.6, 4.8 }; vector a2(4); a2[0] = 1.0/3.0; a2[1] = 1.0/5.0; a2[2] = 1.0/7.0; a2[3原创 2015-04-16 13:41:15 · 586 阅读 · 0 评论 -
caffe interface --- matlab
本文首先介绍一些基础的入门知识,然后分析一个大型工程应用caffe_,从工程的视角分析,该如何设计好一个大型的交互接口。同时,找到matlab性能的瓶颈,正是我们需转载 2016-07-19 15:19:16 · 2355 阅读 · 0 评论