【发布时间】:2012-05-17 14:13:33
【问题描述】:
我正在编写一个涉及 Visual Studio 2010 中的表单的 C++.NET 4.0 程序。我正在向表单添加一个 GraphicsPath。这是我的部分代码:
GraphicsPath^ gp=gcnew GraphicsPath();
gp->AddString("Hello world!", gcnew FontFamily("Arial"), (int) FontStyle::Italic, 26, (new PointF(100,100)), StringFormat::GenericDefault);
编译报错
void System::Drawing::Drawing2D::GraphicsPath::AddString(System::String ^,System::Drawing::FontFamily ^,int,float,System::Drawing::PointF,System::Drawing::StringFormat ^)' : cannot convert parameter 5 from 'System::Drawing::PointF *' to 'System::Drawing::PointF'
所以我改成
GraphicsPath^ gp=gcnew GraphicsPath();
gp->AddString("Hello world!", gcnew FontFamily("Arial"), (int) FontStyle::Italic, 26, *(new PointF(100,100)), StringFormat::GenericDefault);
并得到更多错误
1>LINK:错误 LNK2034:元数据与 COFF 符号表不一致:符号 '??3@$$FYAXPAX@Z' (060000A7) 的元数据不一致 在 MSVCURTD.lib(delete2.obj)
中使用 (0A00001A) 1>LINK : 错误 LNK2034: 元数据与 COFF 符号表不一致:符号 '??3@$$FYAXPAX@Z' (060000A7) 元数据不一致 在 MSVCURTD.lib(ti_inst.obj) 中带有 (0A000029)
1>MSVCURTD.lib(delete2.obj) : 错误 LNK2020: 未解析的令牌 (0A00001A) "void __cdecl operator delete(void *)" (??3@$$FYAXPAX@Z)
1>MSVCURTD.lib(ti_inst.obj):错误 LNK2020:未解析的令牌 (0A000029) "void __cdecl operator delete(void *)" (??3@$$FYAXPAX@Z)
1>D:\Projects\SmartProjector\scratch\VS\Debug\CPPHelloWorld.exe : 致命错误 LNK1120: 2 unresolved externals
应该很简单,只需将指针转换为它实际指向的 PointF,但由于某种我不知道的原因,事情变得复杂了。
您能告诉我使用 System::Drawing::Drawing2D::GraphicsPath::AddString() 函数的正确方法吗?请记住,我使用的是 C++,而不是 C#
【问题讨论】:
-
我看不出两行之间的区别,这也是托管 C++,而不是 C++
标签: .net visual-studio managed-c++