10 2016 档案
摘要:注意编译的时候gcc -o * *.c -levent 需要加上-levent链接库
阅读全文
摘要:wget http://monkey.org/~provos/libevent-1.4.13-stable.tar.gz tar –xzvf libevent-1.4.13-stable.tar.gz cd libevent-1.4.13-stable ./configure --prefix=/h
阅读全文
摘要://每次写代码总是被迭代器的iter->和*iter弄晕,主要是被protobuf弄晕了 #include struct test{ test(){ memset(this, 0, sizeof(test)); } int a; int b; }; int main() { test a, b; a.a = a.b = 0;...
阅读全文
摘要:1.先用:ls -al /usr/lib | grep libevent 查看是否已安装,如果已安装且版本低于1.3,则先通过:rpm -e libevent —nodeps 进行卸载。 2.下载libevent安装包:libevent-1.4.13-stable.tar.gz,然后解压。 3.切换
阅读全文
摘要:class Rational{ public: const Rational operator*( const Rational& rhs); Rational(int num); private: int a; }; Rational::Rational(int num) :a(num) { } const Rational Rational::operator*(...
阅读全文
摘要:以前对于指针直接比较总是不放心,包括std::find用法总感觉不放心,后面发现这种用法是可以的
阅读全文
摘要:#include void fun(int** a) { *a = 0;//改变指针的值 } void fun(int*& a) { a = 0;//改变指针的值 } int main() { int a = 90; int* p = &a; fun(p); return 0; }
阅读全文
摘要:#include void fun(int* a, int num) { for (int i = 0; i < num; ++i) { std::cout << a[i] << " "; } } int main() { int a[5] = {0, 1, 2, 3, 4}; fun(a, 5);//数组名弱化为指针 retu...
阅读全文
摘要:class A { public: virtual void f();//希望派生类重写 void fun();//绝大多数情况下不要重新定义基类的非虚函数,那样会打破公有继承Is-A的关系,而且行为诡异 }; class B : public A { }; int main() { A a; return 0; }
阅读全文
摘要:发现还有好多c++很基础的细节问题,在写代码的时候时常困扰自己,有时间需要研究一下
阅读全文
摘要:extern "C"{ #include #include #include } #include #include #include #pragma comment(lib,"lua.lib") void error(lua_State* L, const char* fmt, ...) { va_list argp; va_start(argp, fmt); ...
阅读全文