
C/C++
文章平均质量分 76
wunderup
这个作者很懒,什么都没留下…
展开
-
C函数调用约定
C中采用了不同的调用方式来调用函数,这里的函数调用概念可能与我们通常所理解的函数调用有所不同,它们指的是处理器在处理函数上的差异。理解这些不同的方式有助于我们来调试程序和链接我们的代码。在此我想讨论一下主要的四种函数调用方法以及之间的区别,它们是__stdcall、__cdecl、__fastcall、thiscall。当然,还有一些更加不常用的函数调用方法比如naked call我也将顺便提及。转载 2010-03-03 10:31:00 · 701 阅读 · 0 评论 -
sort for List.
<br />#include <iostream> #include <vector> #include <list> #include <algorithm> using namespace std; bool myfunction(std::string one, std::string two) { if(one.length() > two.length()) { return true; } else { return false; } }原创 2010-09-30 13:38:00 · 680 阅读 · 0 评论 -
auto_ptr的一个例子
例子:#include #include #include using namespace std; int main() { std::string * str2 = new std::string("hello"); auto_ptr str1(str2); std::string * str3; std::cout length() c_str()原创 2010-09-06 17:09:00 · 702 阅读 · 0 评论 -
class和struct的区别以及类的内存结构
<br /><br />C++中的struct对C中的struct进行了扩充,它已经不再只是一个包含不同数据类型的数据结构了,它已经获取了太多的功能。<br /> struct能包含成员函数吗? 能!<br /> struct能继承吗? 能!!<br /> struct能实现多态吗? 能!!!<br /> 有很多人应该已经知道这样一个事实,但总有些不知道的人,看到这些会感到很惊讶。是的,当我第一次注意到这个事实的时候,我也同样很吃惊。转载 2010-09-06 15:52:00 · 793 阅读 · 0 评论 -
pack的讨论
#include using namespace std; #pragma pack(2) struct S0 { char a; }; struct S1 { char a; long b; }; struct S2 { char c; struct S1 d; long long e; }; int main() { std::cout原创 2010-09-06 15:11:00 · 449 阅读 · 0 评论 -
Boost installation guide
<br /> <!-- /* Font Definitions */ @font-face {font-family:宋体; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:SimSun; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 680460288 22 0 262145 0;}原创 2010-09-21 09:04:00 · 680 阅读 · 0 评论 -
一个int数组内存初始化的讨论
在C++ primer中,有很多关于new int[10]等语言的描述和例子。 如8.4.3中: int * pia = new int[104];pia是一个指向1024的int类型的数组的指针,而这个数组中,所有的数据都是没有被初始化过的。然而,我的例子程序显示,整个数组时被初始化过的,莫非是编译器相关?#include #include using namespace std; int main() { int array[5]; int* arr = new int[10];原创 2010-09-04 21:06:00 · 858 阅读 · 0 评论 -
C++的异常机制
<br /> <br /> <br /> <br /> <br />一篇很好的文章阐述了C++的异常实现方法,牛!<br /> <br /> <br />白杨的C++异常机制的实现方式和开销分析<br /> <br />http://baiy.cn/doc/cpp/inside_exception.htm原创 2010-09-10 09:45:00 · 494 阅读 · 0 评论 -
构造函数内如何调用虚函数
最近看到一个奇怪的问题,虽然我知道答案,测试结果也和我想象的一样,但就是不知道为什么?#include using namespace std; class Object { public: Object() { std::cout原创 2010-09-10 09:19:00 · 521 阅读 · 0 评论 -
Lesson 14: Accepting command line arguments
Normal 0 false false false MicrosoftInternetExplorer4 <!-- /* Font Definitions */ @font-face {font-family:宋体;转载 2010-05-12 16:23:00 · 495 阅读 · 0 评论 -
函数入参的压栈和求值
最近在csdn上看到一个华为的面试题目,折腾了一会儿,才发现是个编译器相关的问题。但是,确实是一个很好的讨论。Mark一下。 程序源代码#include void fStack(int stack1, int stack2){ printf("fStack stack1: %d, fStack stack2: %d/n", stack1, stack2);原创 2010-03-02 17:52:00 · 632 阅读 · 0 评论 -
"delete this;" in the member function
在网上看到了一个NB的文章:最好的C++面试题目。http://blogs.windwardreports.com/davidt/2009/12/the-best-c-interview-question-ever.html 原文:There is no one magical question that can determine if someone is the rig原创 2010-03-03 13:04:00 · 1030 阅读 · 1 评论 -
STL sort的使用
<br /> <br />#include <iostream> #include <vector> #include <time.h> using namespace std; const int vect_len = 10; const int max_value = 100; bool myfunction(int i, int j) { return (i < j); } bool myfunction1(int i, int j) { return (i >原创 2010-09-29 18:03:00 · 551 阅读 · 0 评论