初始化函数中的虚函数调用( 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
相关文档:
http://www.trendcaller.com/2009/05/hadoop-should-target-cllvm-not-java.html
Sunday, May 10, 2009
Hadoop should target C++/LLVM, not Java (because of watts)
< type="text/javascript">
digg_url="http://www.trendcaller.com/2009/05/hadoop-should-target-cllvm-not-java.html";
Over the years, ......
Python 的异常处理机制
Python代码
try:
raise Exception("a", "b")
except Exception,e:
print e
finally:
print "final"
('a', ......
Python内建异常体系结构
BaseException
+-- SystemExit
+-- KeyboardInterrupt
+-- GeneratorExit
+-- Exception
+-- StopIteration
+-- StandardError
| +-- BufferError
| +-- ArithmeticError
| | +-- FloatingPointError
| | +-- OverflowError
| ......
小白和小菜是大学同学,这不快要毕业了,俩人一合计,找个培训班学点东西,武装一下头脑,顺便解决就业问题。
“你们要报哪个班啊?”接待他们的年轻小姐热心地问道。
“你们这里哪个班最好?”小白不假思索地说,“当然是报最好的班啦。”
“我们公司的培训项目都很好”小姐笑 ......
C/C++: 十六进制转10进制源码
收藏
view plain
copy to clipboard
print
?
int
hex_char_value(
char
c)
{
if
(c >=
'0'
&& ......