随笔分类 -  C/C++ Language

C++ 试题
该文被密码保护。
posted @ 2011-05-31 09:48 sun_kang 阅读(1) 评论(0) 推荐(0)
Memory leak detector(C++)
摘要:Memory leak detector(C++)This is a simple solution for memory leak detector.For any C++ software source under windows, please follow these steps: 1. You need to put MemoryTracker.h and MemoryAllocateTracker.h into include folder, and force all *.cpp file to include MemoryTracker.h first(when using M 阅读全文
posted @ 2011-05-20 15:16 sun_kang 阅读(2156) 评论(0) 推荐(0)
Appearing and Disappearing consts in C++
摘要:If you write “int i;” in C++, i’s type seems obvious: int. If you write “const int i;”, i’s type seems equally obviously to be const int. Often, these types are exactly what they seem to be, but sometimes they’re not. Under certain circumstances, C++ treats non-const types as const, and under others 阅读全文
posted @ 2011-05-17 17:28 sun_kang 阅读(390) 评论(0) 推荐(0)
Know When to Use an Active Object Instead of a Mutex
摘要:Let's say that your program has a shared log file object. The log file is likely to be a popular object; lots of different threads must be able to write to the file; and to avoid corruption, we need to ensure that only one thread may be writing to the file at any given time.Quick: How would you 阅读全文
posted @ 2011-05-17 10:59 sun_kang 阅读(402) 评论(0) 推荐(0)
C++0x standard & features in VC10
摘要:C++ 0x standard [2011 draft]2011 Proposed Draft Technical Report on C++ Library ExtensionsC++0x FAQ C++0x Core Language Features In VC10Part1: Lambdas, auto, and static_assertThe Visual C++ compiler in the Microsoft Visual Studio 2010 September Community Technology Preview (CTP) contains support for 阅读全文
posted @ 2011-05-12 00:08 sun_kang 阅读(1248) 评论(0) 推荐(0)
Reversing Microsoft Visual C++
摘要:Reversing Microsoft Visual C++ Part I: Exception HandlingAbstractMicrosoft Visual C++ is the most widely used compiler for Win32 so it is important for the Win32 reverser to be familiar with its inner working. Being able to recognize the compiler-generated glue code helps to quickly concentrate on t 阅读全文
posted @ 2011-05-06 12:56 sun_kang 阅读(2954) 评论(0) 推荐(0)
C talk
摘要:Array & Pointer Are they equivalent?Consider the following two pieces of code:int *p;...c = p[1];int p[10];...c = p[1];Are they equivalent? If not, which is faster? The answer is here:Disassembled for c = p[1]:mov eax,dword ptr[p]mov ecx,dword ptr[eax+4]mov dword ptr[c],ecxDisassembled for c = p 阅读全文
posted @ 2008-04-16 22:05 sun_kang 阅读(258) 评论(0) 推荐(0)
ACM/ICPC 集:
摘要:ACM/ICPC在线题库集锦:网址:http://acm.uva.es/简称: uva全称: Valladolid Programming Contest Site所在国:西班牙提交方式:web方式和email方式说明:可能是世界上名气最大,最古老的在线题库了。收集了N卷的题目,许多国家队的高手都是从这里练出来的。题目包括历届ACM/ICPC分区赛试题、总决赛试题以及很多其他网友自己出的题目。题目类型比较全面,难度较平均,但是测试数据非常刁钻,而且经常更新旧的数据,在别的地方能通过的程序到了uva就可能无法通过。定期有比赛,并且可以利用它的系统主办自己的比赛。唯一的缺点是系统太烂,比赛的时候经 阅读全文
posted @ 2006-12-17 23:45 sun_kang 阅读(403) 评论(0) 推荐(0)
C++的RTTI 观念和用途
摘要:自从1993年BjarneStroustrup〔注1〕提出有关C++的RTTI功能之建议,以及C++的例外处理(exceptionhandling)需要RTTI;最近新推出的C++或多或少已提供RTTI。然而,若不小心使用RTTI,可能会导致软件弹性的降低。本文将介绍RTTI的观念和近况,并说明如何善用它。 什么是RTTI? 在C++环境中,标头档(headerfile)含有类别之定义(classdefinition)亦即包含有关类别的结构资料(representationalinformation)。但是,这些资料只供编译器(compiler)使用,编译完毕后并未留下来,所以在执行时期(at 阅读全文
posted @ 2006-10-04 13:44 sun_kang 阅读(435) 评论(0) 推荐(0)
C 数据类型
摘要:C语言有五种基本数据类型:字符、整型、单精度实型、双精度实型和空类型。尽管这几种类型数据的长度和范围随处理器的类型和C语言编译程序的实现而异,但以b i t为例,整数与CPU字长相等,一个字符通常为一个字节,浮点值的确切格式则根据实现而定。对于多数微机,表2 - 1给出了五种数据的长度和范围。 表中的长度和范围的取值是假定C P U的字长为1 6 b i t。C语言还提供了几种聚合类型(aggregate types),包括数组、指针、结构、共用体(联合)、位域和枚举。这些复杂类型在以后的章节中讨论。除v o i d类型外,基本类型的前面可以有各种修饰符。修饰符用来改变基本类型的意义,以便更准 阅读全文
posted @ 2006-09-30 10:54 sun_kang 阅读(716) 评论(0) 推荐(0)
C浮点数据格式
摘要:#include <stdio.h>int main(int argc, char *argv[]){ float p = 5.1f; int f = (int)(p*100); printf("%d", f); getch( ); return 0;}我想要输出 510,可是机器nnd居然输出509(竟然敢扣我工钱)。到底是what's wrong。我上看下看,左看又看,看了又看,就是发现不了错误。于是我试着把5.1改成5.5,一切正常啊。捣鼓了N个小时后猜想,莫非是浮点数的表示问题,于是花了很久找到浮点数的机器表示方法,照着规定克隆操作了一下。(据说 阅读全文
posted @ 2006-09-30 09:42 sun_kang 阅读(750) 评论(0) 推荐(1)
talking C++ STL
摘要:地球人都知道 C++ 的 string 没有 toupper ,好在这不是个大问题,因为我们有 STL 算法:string s("heLLo");transform(s.begin(), s.end(), s.begin(), toupper);cout << s << endl;transform(s.begin(), s.end(), s.begin(), tolower);cout << s << endl;当然,我知道很多人希望的是 s.to_upper() ,但是对于一个这么通用的 basic_string 来说,的 阅读全文
posted @ 2006-08-20 11:39 sun_kang 阅读(296) 评论(0) 推荐(0)
C++ books
摘要:入门教程 :《C++编程你也行》,即将由人民邮电出版社出版。译者徐波先生《You Can Do It!: A Beginner's Introduction to Computer Programming》。完全的C++编程新手可以阅读Francis Glassborow的这本新书《Accelerated C++中文版》,中国电力出版社Andrew Koenig, Barbara E. Moo, Accelerated C++: Practical Programming by Example《C++ Primer (3RD)中文版》,中国电力出版社《Essential C++中文版》 阅读全文
posted @ 2006-08-16 11:43 sun_kang 阅读(374) 评论(0) 推荐(0)