
c++
文章平均质量分 55
lwj1396
这个作者很懒,什么都没留下…
展开
-
iOS要点散记
KCFStringEncodingGB_18030_2000 gbk/gb2321KCFStringEncodingISOLatin1 iso-8559-1wchar_t 在mac下是4个字节,在linux下是2个。。。原创 2012-10-23 19:23:20 · 830 阅读 · 0 评论 -
S60: cleanup stack
如果是局部指针的话,需要这样(否则heap内的内存无法回收): void SafeFunctionL(){CAnotherClass* theObject = new (ELeave) CAnotherClass();// Push to the cleanup stack before calling// any methods that may leave.Clea原创 2009-09-05 14:46:00 · 719 阅读 · 0 评论 -
USACO:Section 1.1 Friday the Thirteenth
/*ID:lwj13961 TASK:fridayLANG: C++*/#include#include#includeusing namespace std;bool isleapyear(int year){ if(year%100!=0&&year%4==0) return true; if(year%100==0&&year%400=原创 2009-06-29 17:23:00 · 906 阅读 · 0 评论 -
NewL and NewLC
理解 NewL ConstructL NewLC ELeave初学Symbian开发,第一件感觉迷惑的事情是CleanupStack 第二件肯定是随处可见的NewL,NewLC,ConstructL。这些函数的出现依然和内存泄漏有关,这是一种被称为两步构造的机制,英文叫Two-phase Construction。我知道C++里面的 new 操作符实际上完成2件事,第一根据对象类的大小在堆上分转载 2009-08-31 16:44:00 · 741 阅读 · 1 评论 -
USACO:Section 1.1 Greedy Gift Givers
气死我了,提交半天么成功,原来他们的“_”是指空格,气死俺了。 /*ID:lwj13961 TASK:gift1LANG: C++*/#include#include#include#include#includeusing namespace std;class person { public: string name;原创 2009-06-29 15:47:00 · 763 阅读 · 0 评论 -
USACO:Section 1.1 Your Ride Is Here
LANG: C++*/#include#include#includeusing namespace std;int main(int argc,char** argv){ string comet; string group; unsigned long cometresult=1; unsigned long groupresult=1原创 2009-06-28 20:36:00 · 753 阅读 · 0 评论 -
2 "sizeof" tips
char a[] = "hello world"; char *p = a; cout cout 计算数组和指针的内存容量 void Func(char a[100]) { cout} 数组退化为指针原创 2009-05-29 10:43:00 · 666 阅读 · 0 评论 -
symbian 下 不定参数的函数
e32def.h contains the va_list, va_start and va_end macros. // Definitionint math (const OperatorType ty ...){va_list ap; // param listva_start(ap,ty); // where to start in the list i.e. after tyin原创 2009-08-06 14:20:00 · 582 阅读 · 0 评论 -
fstream 将类写入文件
将类写入文件是比较通用的任务,是写文件索引的基础。进一步可以将b+ tree等东西写入文件/* * ===================================================================================== * * Filename: classtfile.cpp * * Description: 将类写入文件,原创 2008-12-26 16:26:00 · 2124 阅读 · 2 评论 -
c++ string 和 stl算法
toupper,tolower地球人都知道 C++ 的 string 没有 toupper ,好在这不是个大问题,因为我们有 STL 算法:string s("heLLo");transform(s.begin(), s.end(), s.begin(), ::toupper);cout transform(s.begin(), s.end(), s.begin(), ::tolower);cou转载 2008-12-25 20:33:00 · 5287 阅读 · 1 评论 -
线程
作者:CppExplore 网址:http://www.cppblog.com/CppExplore/废话不多说,详细介绍使用线程的优点好处请参考baidu、google。一、线程使用场景。使用线程的方式大致有两种:(1)流水线方式。根据业务特点,将一个流程的处理分割成多个线程,形成流水线的处理方式。产生的结果:延长单一流程的处理时间,提高系统整体的吞吐能力。(2)线程池方式。针对处理时间比较长且转载 2008-12-24 11:45:00 · 1566 阅读 · 0 评论 -
c++ 测试篇
作者:CppExplore 网址:http://www.cppblog.com/CppExplore/在c++的世界里,程序设计的优雅让位于程序的稳定性、健壮性。“好程序是测出来的”这句话在C++领域里得到了充分体现。下面是我在开发中使用的测试方法,抛砖引玉,和大家交流下。测试期间,关闭对core文件的限制,使用命令:ulimit -c unlimited(1)开发阶段,使用cppunit维护转载 2008-12-24 11:04:00 · 2645 阅读 · 0 评论 -
Symbian 中各种提示、输入对话框的使用
1、非阻塞提示框symbian定义了几个提示类,分别是:confirm类:CAknConfirmationNoteinfo类: CAknInformationNotewarning类:CAknWarningNoteerror类:CAknErrorNote头文件:aknnotewrappers.hlib: avkon.lib eikcdlg.lib eikctl.libCode:转载 2009-09-15 10:09:00 · 703 阅读 · 0 评论 -
Symbian C++ 各种类型之间的转换
1.TTime转TBuf型TBuf theTime;//存储转换后的时间TTime tt;tt.HomeTime();_LIT(KTimeFormat,"%Y%M%D%1-%2-%3 %H:%T:%S");//格式为:2006-03-04 12:12:12tt.FormatL(theTime,KTimeFormat);//FormatL()会以KTimeFormat字符串的形式来格转载 2009-09-15 10:31:00 · 628 阅读 · 0 评论 -
JSPP – Morph C++ Into Javascript
<br /><br />C++ has a new standard called C++0x (Wikipedia, Bjarne Stroustrup) that includes many interesting features such as Lambda, For Each, List Initialization ... Those features are so powerful that they allow to write C++ as if it was Javascript.<br转载 2011-04-25 10:38:00 · 8409 阅读 · 0 评论 -
三个编程规范
<br />google python style guide http://google-styleguide.googlecode.com/svn/trunk/pyguide.html<br />google c++ style guide http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml<br />google objectC style guide http://google-styleguide.googleco原创 2011-03-12 12:45:00 · 1080 阅读 · 0 评论 -
中途需要产生const变量的一些方法
<br />需求:<br />int c =0;<br />// the value of c is initialized here<br />switch(someVar){<br /> case foo: c =3;break;<br /> case bar: c =4;break;<br /> default: c =42;// what else?<br />}<br />// now c is constant<br />ASSUME_CONST_FROM_NOW(c)// 中途产生翻译 2011-01-14 19:15:00 · 910 阅读 · 0 评论 -
stl vector插入过程
<br /> 1. Vec.push_back(a);<br /> 申请1个内存空间, 存放a. copy 1 次<br /> 2. Vec.push_back(b);<br /> a> 发现内存空间不够,于是扩大为原来的2倍.<br /> b> 然后将a,b copy到新的内存空间 这里copy 2 次<br /> c> 然后释放原来空间原创 2011-01-14 19:09:00 · 1270 阅读 · 0 评论 -
qt for s60 资料集
转贴个Qt-S60的开发者资源列表, 原文贴于Nokia论坛:http://discussion.forum.nokia.com/forum/showthread.php?p=637780Qt technology now becomes an option for developers to develop application on S60 devices. This d转载 2010-04-30 10:26:00 · 986 阅读 · 0 评论 -
QT错误:undefined reference to `WinMain@16'
新装qt编译例子不通过。。。原因是没有set path。 set QTDIR=E:/Qt/2010.02.1/qtset MINGW=E:/Qt/2010.02.1/mingw原创 2010-03-04 10:31:00 · 4199 阅读 · 0 评论 -
(转)用GDB调试程序
用GDB调试程序GDB是一个强大的命令行调试工具。大家知道命令行的强大就是在于,其可以形成执行序列,形成脚本。UNIX下的软件全是命令行的,这给程序开发提代供了极大的便利,命令行软件的优势在于,它们可以非常容易的集成在一起,使用几个简单的已有工具的命令,就可以做出一个非常强大的功能。于是UNIX下的软件比Windows下的软件更能有机地结合,各自发挥各自的长处,组合成更为强劲的功能。而转载 2009-12-02 16:24:00 · 900 阅读 · 0 评论 -
(转)使用C/C++扩展Python
使用C/C++扩展Python翻译:gashero如果你会用C,实现Python嵌入模块很简单。利用扩展模块可做很多Python不方便做的事情,他们可以直接调用C库和系统调用。为了支持扩展,Python API定义了一系列函数、宏和变量,提供了对Python运行时系统的访问支持。Python的C API由C源码组成,并包含 “Pyth转载 2009-12-02 14:50:00 · 4030 阅读 · 0 评论 -
dlopen加载c++ 函数及类
问题所在 有时你想在运行时加载一个库(并使用其中的函数),这在你为你的程序写一些插件或模块架构的时候经常发生。 在C语言中,加载一个库轻而易举(调用dlopen、dlsym和dlclose就够了),但对C++来说,情况稍微复杂。动态加载一个C++库的困难一部分是因为C++的name mangling(译者注:也有人把它翻译为“名字毁坏”,我觉得还是不翻译好),另一部分是因为dl转载 2010-01-17 21:13:00 · 13447 阅读 · 1 评论 -
很好的技术文件集合
C Introduction to C Programming C Optimization Tutorial Compiling C and C++ Programs on UNIX Systems - gcc/g++ Building and Using Static and Shared C Libraries Programming in C: UNIX System Calls and原创 2009-11-20 14:12:00 · 5173 阅读 · 10 评论 -
c++资源索引
1,前言 无数次听到“我要开始学习C++!”的呐喊,无数次听到“C++太复杂了,我真的学不会”的无奈。Stan Lippman先生曾在《C++Primer》一书中指出“C++是最为难学的高级程序设计语言之一”,人们常将“之一”去掉以表达自己对C++的敬畏。诚然,C++程序设计语言对于学习者的确有很多难以逾越的鸿沟,体系结构的庞大,应接不暇并不断扩充的特性……除转载 2008-12-20 20:14:00 · 1381 阅读 · 1 评论 -
用boost.python为python写c/c++扩展曲折配置最终成功历程
捣鼓了1天多才完成,sign。。。。正确步骤如下:1 安装boost.python 单独编译boost.python: bjam -sTOOLS=gcc --with-python --build-type=complete 编译所有: bjam -sTOOLS=gcc --build-type=complete 清除所有编译: bjam -sTOOLS=gcc --cl原创 2008-12-17 18:38:00 · 4116 阅读 · 0 评论 -
boost smart pointer 笔记
/* * ===================================================================================== * * Filename: T_smartpointer.cpp * * Description: smartpointer of boost * * Version: 1.0原创 2008-12-12 10:45:00 · 4875 阅读 · 0 评论 -
虚拟析构函数
1 纯虚析构函数要提供一个函数体。2 一般析构函数都弄成虚拟的。3 析构函数中,只有成员函数的本地版本被调用,虚机制被忽略。4 删除一个void指针并不调用析构函数。原创 2008-08-30 11:07:00 · 3964 阅读 · 0 评论 -
返回值优化
return Integer(left.i+right.i); //创建一个临时对象并返回他,不会调用析构函数,效率高。Interger tmp(left.i+right.i);return tmp; //创建了局部对象,有析构函数。原创 2008-08-27 10:09:00 · 4159 阅读 · 2 评论 -
异常学习
#include exception>#include iostream>using namespace std; void terminator() ...{ cout "Ill be back!" endl; exit(0);} void (*old_terminate)() = set_terminate(terminator); class Botch ...{public:原创 2008-04-01 14:04:00 · 3663 阅读 · 0 评论 -
catch基类和子类异常
#include iostream>using namespace std;class X ...{public: class Trouble ...{}; class Small : public Trouble ...{}; class Big : public Trouble ...{}; void f() ...{ throw Big(); }};int main() ...{原创 2008-04-01 10:09:00 · 4469 阅读 · 1 评论 -
more effective c++笔记
原创 2008-03-09 19:02:00 · 3673 阅读 · 0 评论 -
const
1 const double *ptr 指向double常量,ptr自己并不是常量2 double *const ptr ptr自身是常量3 const引用可以用不同类型的对象初始化,也可以是不可寻址的值。const 引用是只读的。double dval = 3.1415926;//对于const才合适const int &ir = 1024;cons原创 2008-03-09 19:28:00 · 3691 阅读 · 0 评论 -
多态,操作符重载
#include "stdafx.h"#includeiostream>using namespace std;class Base...{public : virtual Base& operator=(const Base& a) ...{ cout"Base ="endl; return *this; }};class Devide:publ原创 2007-10-02 18:38:00 · 4049 阅读 · 0 评论 -
纯c++读写文件方式
#include "stdafx.h"#includeiostream>#includevector>#includealgorithm>#includefstream>#includestring>using namespace std;int _tmain(int argc, _TCHAR* argv[])...{ ifstream infile("ReadMe.txt"); o原创 2007-09-30 17:03:00 · 3725 阅读 · 0 评论 -
pointer to function and pointer to member function
的确很好,不过功力未足,看至后面便云里雾里了。#includeiostream>#includevector>using namespace std;class F...{public : F()...{} string functionA(string a) ...{ cout "it is A"endl;原创 2007-09-30 17:00:00 · 3996 阅读 · 0 评论 -
fatal error LNK1120: 3 unresolved externals错误处理
用vs2005写c++项目,定义了AList类,在AList.h中写了类定义,有3个函数不是inline的,定义写在了AList.cpp中。但每次编译项目,那3个函数便报错DataStruct.obj : error LNK2001: unresolved external symbol "public: virtual bool __thiscall AList::insert(int co原创 2007-10-07 19:15:00 · 11440 阅读 · 0 评论 -
递归逆转字符串
string RecuriseRevalsal(string &s)...{ if(s.size()>1) ...{ string::iterator i = s.begin(); char end = *i; s.erase(s.begin(),s.begin()+1); RecuriseRevalsal(s);原创 2007-10-02 10:52:00 · 3920 阅读 · 0 评论 -
初试linux下动态链接库,求牛人帮忙阿~!
直接上代码,一个跟踪内存分配的类,可以检测是否有内存泄露: 头文件#ifndef MEMCHECK_H#define MEMCHECK_H#include#ifdef _cplusplusextern "C"{#endifvoid* operator new(std::size_t ,const char* ,long);void* operator new[](std::size_t原创 2008-09-14 15:24:00 · 4145 阅读 · 1 评论 -
private是针对类型的
1、 template class Myclass { private:T value; public: void assign(const MyClass&x) {原创 2008-09-11 19:57:00 · 4163 阅读 · 1 评论