易截截图软件、单文件、免安装、纯绿色、仅160KB

初始化函数中的虚函数调用( C++ vs python )

代码+结果,不做解释
当然,对于python没有virtual function一说,估计当作对比一个例子看看吧。
#include <iostream>
using namespace std;
class base
{
public:
virtual void foo() { cout << "base" << endl; }
base() { foo() ;}
};
class derive: public base
{
public:
derive() { foo(); }
virtual void foo() { cout << "derive" << endl; }
};
int main()
{
derive d;
return 0;
}

结果:
base
derive
class base(object):
def __init__( self ):
self.foo()
def foo( self ):
print "base"
class derive( base ):
def __init__( self ):
super( derive , self ).__init__()
self.foo()
def foo( self ):
print "derive"
d = derive()

结果:
derive
derive


相关文档:

JAVA调用c++生成的DLL

    最近经常和公司做JAVA的兄弟们打交道,由于需要统加密算法,所以要求做一个加密的DLL文件供兄弟们调用,根据网上各位大虾们的经验,在加上个人在摸索过程中的体会,现在将流程以及个人心得贴上,以供以后漫漫程序生涯参考,如有不对的还请各位大力指正。
    第一步是编写java类, ......

Optimizing Your C/C++ Applications


C/C++ optimizing compilers are great--but there *are* a few techniques for hand-tuning your code to run as efficiently as possible on the AMD Athlon64 and Opteron processors, especially when developing DLLs, device drivers, or other performance-bound pieces of code.
Alan Zeichick  
Share | ......

Java与C++的多态

没有必要用一堆绕口的形容词来描述什么叫多态,只举出几个关键点。
    设:gun为父类,shootgun和pistol为gun的子类。
    Java:
    class gun {
        void shoot() {
          ......

C/C++函数的借口定义

1、在C文件中调用C++文件中定义的文件
直接的方法是在C++ 文件的头部添加如下代码段:
extern "C"
{
      int API(int A);
}
2、C++接口的方法
在C++中调用C的函数,在C头文件中加入如下代码:
#ifdef __cplusplus          // 开始
exte ......

memcachde 与 c/c++ 应用

修改makefile,在LIBS里面加上-lmemcached,比如原来 gcc test.c,现在 gcc test.c -lmemcached。这个库就是libmemcached提供的。
然后添加#include<libmemcached/memcached.h>,这个文件也是libmemcached提供的。
主函数里面需要添加:
    memcached_st *memc;
    uint32_t&nbs ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号