namespace:
文件的引用,为函数划定作用域,限制函数体内变量的作用域。相当于maya中的reference。
例如:
#include <maya/MMatrix.h>
#include <maya/MItMeshPolygon.h>
#include <maya/MVector.h>
namespace testFile
{
MString File;
unsigned int numberSize;
namespace other {
MString File;
unsigned int numberSize;
}
}
void main(){
namespace f = testFile; // 别名: 相当于python中的标签(对象另一个名称)
f::other::File = MString("filepath"); // 设置
cout << "the file path is " << f::other::File << endl;
return;
}
using:
表示省略,和namespace搭配使用表示可以省略掉空间域名。
例如:
#pragma once
#include <maya/MMatrix.h>
#include <maya/MItMeshPolygon.h>
#include <maya/MVector.h>
namespace testFile
{
MString File;
unsigned int numberSize;
namespace other {
MString File;
unsigned int numberSize;
}
}
void main(){
using namespace testFile;
other::File = MString("filepath"); // 设置
cout << "the file path is " << other::File << endl;
return;
}