易截截图软件、单文件、免安装、纯绿色、仅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


相关文档:

Python异常处理体系简介

Python内建异常体系结构
BaseException
+-- SystemExit
+-- KeyboardInterrupt
+-- GeneratorExit
+-- Exception
+-- StopIteration
+-- StandardError
|    +-- BufferError
|    +-- ArithmeticError
|    |    +-- FloatingPointError
|    |    +-- OverflowError
|   ......

C/C++单元测试理论精要(六)

2.1 可测性问题详解(2)
   
    接下来我们讨论重点问题:覆盖输入。一个函数,输入会有哪些呢?输入包括两方面:外部输入,内部输入。外部输入容易理解,就是函数外部可以设定的输入,包括参数,全局变量,成员变量。
    
   
  &nb ......

C/C++文件操作

在C++中,可以使用多种方法对文件进行操作,如基于C的文件操作、基于C++的文件操作等等;
◆基于C的文件操作
在ANSI C中,对文件的操作分为两种方式,即流式文件操作和I/O文件操作,下面就分别介绍之。
一.流式文件操作
这种方式的文件操作有一个重要的结构FILE,FILE在stdio.h中定义如下:
 typedef struct {
i ......

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 | ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号