这是一个变量或函数 [英] is this a variable or function
问题描述
我只是看通过google的非本地平均值算法的实现(感谢google代码搜索),并遇到这个功能镜像。
I was just looking through implementation of non local means algorithm via google (thanks google for code search) and come across this function mirror.
template<typename T,typename U,bool N>
inline int
boundaryExpansion::helperBase<T,U,N>::mirror(const int src,
const int size,
const int last) const {
const int32 alpha(src%size);
if (alpha>=0) {
return (((src/size) & 0x00000001) != 0) ? last-alpha : alpha;
}
return (((src/size) & 0x00000001) == 0) ? -alpha-1 : size+alpha;
}
我感兴趣的是
const int32 alpha(src%size);
现在什么是alpha?函数或变量?这个语法是什么意思?这是一个变量声明?
Now what is alpha here? A function or a variable? What this syntax means? Is this a variable declaration?
推荐答案
这是一个变量声明。声明形式:
This is a variable declaration. A declaration of the form:
type variablename = value;
本质上等效于:
type variablename(value);
无论类型
是 - 它是一个用户定义的类还是一个内置的类型。注意,相反并不总是这样 - =
语法要求有一个可访问的复制构造函数。
This is the case regardless of what type
is - whether it is a user-defined class or a built-in type. Note that the reverse is not always the case - the =
syntax requires that there be an accessible copy constructor.
由于类似的原因,您可以使用构造函数语法来转换算术类型,如: x = int(42.0);
For similar reasons, you can cast arithmetic types using the constructor syntax, as in: x = int(42.0);
这篇关于这是一个变量或函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!