【发布时间】:2014-03-24 23:29:48
【问题描述】:
我是 Visual c++ 的新手,我有以下代码:
ref class Book sealed
{
public:
Book(std::string title,std::string author,int year);
void setTitle(std::string title);
std::string getTitle() const;
int getYear() const;
void setYear(int year);
void setAuthor(std::string author_);
std::string getAuthor() const;
private:
std::string title_;
std::string author_;
int year_;
};
当我尝试编译它时,我收到以下错误:
{ctor} signature of public member contains native type。我想这是因为我使用的是 std::string 而不是 Platform::String,我该如何解决?
【问题讨论】:
-
这看起来不像 C++。我认为你需要另一个语言标签。
-
这是托管 C++,而不是 C++
-
@DavidKernin 对不起,我的错。
-
是C++/CLI,微软为.NET平台改编的C++。它不是标准的 C++。
-
不,它允许这样做。这就是 C++/CX,一种允许 VB.NET 和 Javascript 等语言直接调用 C++ 代码的语言扩展。这当然不能与 std::string 一起使用,Javascript 知道有关该 C++ 类的 bean。