我正在構建一個C++項目,我想創建一個全局自定義對象。我創建了一個名爲Material的自定義類。C++ - 訪問全局變量對象
rt.h
template<typename T>
class Material
{
public:
Vec3<T> ka, kd, ks, kr;
T sp, transparency, reflectivity;
Material() {
ka = Vec3<T>(0);
kd = Vec3<T>(0.0, 0.0, 0.0);
ks = Vec3<T>(0.0, 0.0, 0.0);
sp = 0.0;
kr = Vec3<T>(0.0, 0.0, 0.0);
reflectivity = 0.0;
transparency = 0.0;
}
};
在我rt.cpp文件的頂部,我有以下。
#include <"rt.h">
Material<float> currentMaterial();
後來我打電話currentMaterial,當我打電話得到一個錯誤
raytracer.cpp:294:3: error: base of member reference is a function; perhaps you meant to call it with no arguments?
currentMaterial.ka = Vec3<float>(kar, kag, kab);
:
currentMaterial.ka = Vec3<float>(kar, kag, kab);
感謝