摘要: DLL hell 是指 Windows 系统上动态库的新版本覆盖旧版本,且新版本不能兼容旧版本的问题。例如:装新软件,但原有的软件运行不起来了。Linux 系统下也同样面临着和 Windows 一样的动态库多版本的问题,其严重影响软件的升级和维护。那么此问题该如何解决的呢?Linux 系统为解决这个... 阅读全文
posted @ 2014-11-29 16:13 没出没 阅读(1530) 评论(0) 推荐(1) 编辑
摘要: 今天看到一个很有趣的程序,如下:int main(){ const int a = 1; int *b = (int*)&a; *b = 21; printf("%d, %d", a, *b); return 0;}当我第一眼看到这个程序的时候,我想当然的认为输出结果是21, 21,但是我错了一时很难理解,于是我又输出了它们的地址:int main(){ const int a = 1; int *b = (int*)&a; *b = 21; printf("%d, %d", a, *b); printf("\n%p, %p&q 阅读全文
posted @ 2013-08-24 22:03 没出没 阅读(4068) 评论(8) 推荐(2) 编辑
摘要: 《高质量c++和c编程》7.4 指针参数是如何传递内存的一节中写道void GetMemory(char *p, int num) { p = (char *)malloc(sizeof(char) * num); } void Test(void) { char *str = NULL; GetMemory(str, 100); // str 仍然为 NULL strcpy(str, "hello"); // 运行错误 }无法返回内存,可以用如下方式void GetMemory2(char **p, int num) { *p = (char *)malloc(siz.. 阅读全文
posted @ 2013-07-25 22:09 没出没 阅读(1502) 评论(7) 推荐(2) 编辑
摘要: class A{public: A(int arg1, int arg2); ~A(); A &operator = ( A &other); A operator + ( A &other);private: int a, b;};A::A(int arg1, int arg2){ a = arg1; b = arg2;}A::~A(){}A &A::operator=( A &other){ if (this == &other) { return *this; } this->a = other.a; ... 阅读全文
posted @ 2013-07-22 17:31 没出没 阅读(974) 评论(0) 推荐(0) 编辑
摘要: c++的容器中有位对象bitset,但是个人认为最大的问题是定义是必须指定常数大小,比如bitset bit;无法实现int n = 3;bitset bit;所以我自己查了一些资料,实现了能用变量定义的Bitsclass Bits{ public: Bits(int numOfBits); virtual ~Bits(); bool Set(int arg); bool Clr(int arg); bool Test(int arg); class BitsProxy {。。。。。 ... 阅读全文
posted @ 2013-07-17 20:34 没出没 阅读(426) 评论(0) 推荐(0) 编辑
摘要: 在所有的预处理指令中,#pragma 指令可能是最复杂的了,它的作用是设定编译器的状态或者是指示编译器完成一些特定的动作。#pragma指令对每个编译器给出了一个方法,在保持与C和C++语言完全兼容的情况下,给出主机或操作系统专有的特征。依据定义,编译指示是机器或操作系统专有的,且对于每个编译器都是不同的。 其格式一般为: #pragma para 其中para为参数,下面来看一些常用的参数。(1)message 参数 message参数是我最喜欢的一个参数,它能够在编译信息输出窗口中输出相应的信息,这对于源代码信息的控制是非常重要的。其使用方法为: #pragma message(" 阅读全文
posted @ 2012-10-24 10:24 没出没 阅读(309) 评论(0) 推荐(0) 编辑
摘要: #include <algorithm>#include <functional>#include <iostream>#include <iterator>#include <list>#include <string>using namespace std;class Salesperson{ public: Salesperson( const string& name = "", int sales = 0,int district = 0 ); bool operator>( c 阅读全文
posted @ 2012-09-27 16:14 没出没 阅读(598) 评论(0) 推荐(0) 编辑
摘要: 每个分支比较经典的书可能不止一本,有些适合本科生的,有些是适合研究生的。可以只买我后面打了(重点推荐)的,呵呵。比较多,大概30本左右。先是离散数学,数据结构,算法,计算理论部分1. 离散数学及其应用(重点推荐)2. 具体数学:计算机科学基础(重点推荐)3. 数据结构与算法分析--C语言描述 数据结构与算法分析--C++描述 数据结构与算法分析--Java 语言描述(重点推荐) 这3本是一个作者写的,只是不同语言版本,内容基本是一样的,你可以任选一本。我更推荐Java的,北美现在绝大部分大学数据结构都用Java讲了。不过Java版本的好像绝版了,china pub还有二手书再买,说是2手,其实 阅读全文
posted @ 2012-09-22 16:32 没出没 阅读(1276) 评论(0) 推荐(0) 编辑
摘要: 在这里我总结一下网上看来的方法,以map为例:方法一:#include <iostream>#include <utility>#include <string>#include <map>using namespace std;bool my_compare(const string &str1, const string &str2){ return str1 > str2;}typedef bool (*comp)(const string &,const string &);int main(int 阅读全文
posted @ 2012-06-14 13:04 没出没 阅读(525) 评论(0) 推荐(1) 编辑
摘要: 1 class Base 2 { 3 int a = 1; 4 void display() 5 { 6 System.out.println("base"); 7 } 8 } 9 10 class Derive extends Base11 {12 int a = 2;13 int b = 3;14 void display()15 {16 System.out.println("derive");17 }18 void displayA()19 {20 ... 阅读全文
posted @ 2012-03-08 19:57 没出没 阅读(359) 评论(0) 推荐(0) 编辑