【发布时间】:2014-08-29 11:13:43
【问题描述】:
在 KinFu remake 的源代码中,我发现了以下结构:
kfusion::OpenNISource::OpenNISource() : depth_focal_length_VGA (0.f), baseline (0.f),
shadow_value (0), no_sample_value (0), pixelSize (0.0), max_depth (0) {}
: 后面的参数在类 kfusion::OpenNISource 中声明。函数 OpenNISource() 也在此类中声明。由于我是 C++ 新手,我认为该函数继承并声明了变量...(?)
那么下面的代码是否会将变量(foo, bar)和值(0, 1.0f)添加到函数中?
class A
{
public:
fn ();
fn (int qux);
int foo;
float bar;
};
A::fn() : foo(0), bar(1.0f) {}
如果是这样,这些变量是否也会添加到 fn(int qux) 中??
【问题讨论】:
-
只有构造函数才能做到这一点
标签: c++ function inheritance