.Net里有一个System namespace, 而Nebual3里也有一个. 它们在一起使用时会产生冲突, 如下:
这是纯C++的部分:
#pragma once
namespace Math
{
class Vector3
{
public:
float x, y, z;
};
}// namespace Math
namespace System
{
class NativeCpp
{
public:
NativeCpp()
{
position.x = 0;
position.y = 0;
position.z = 0;
}
private:
Math::Vector3 position;
};
}// namespace System
新建一个Console CLR Application:
// TestCLR.cpp : main project file.
#include "stdafx.h"
#include "NativeCpp.h"
using namespace System;
int main(array<System::String ^> ^args)
{
Console::WriteLine(L"Hello World");
NativeCpp native;
return 0;
}
编译会产生以下错误:
Error 1 error C2039: 'Vector3' : is not a member of 'System::Math' d:\documents\visual studio 2010\projects\testclr\testclr\NativeCpp.h 28 1 TestCLR
如果不改动native C++的部分, 怎么消除这个错误呢?
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/xoyojank/archive/2010/09/20/5896036.aspx
------解决方案--------------------------------------------------------
把你的空间名都带上system::math