1

我想知道如何在 Visual C++ 中编写非托管异常?

#include <string>
#include <exception>

using namespace std;
using namespace System;

class GraphException : public Exception
{
public:
    GraphException() { }
//  GraphException(string message) : Exception (message)
//  { }
//  GraphException(string message, Exception inner) : Exception (message, inner)
//  { }
};

这不起作用我收到以下错误,

错误 1 ​​错误 C3625:“GraphException”:非托管类型无法从托管类型“System::Exception”派生 c:\breadthfirst\graph\graphexception.h 10 1 breadthFirst

有人可以帮帮我吗?

4

1 回答 1

5

派生自std::exception而不是Exception.

更好的是从stdexcept.

于 2012-05-16T18:01:06.193 回答