【发布时间】:2012-01-05 08:47:35
【问题描述】:
不知道为什么这不会编译。我在这里犯了什么样的错误,我该如何解决?我正在尝试编译在示例中找到的此代码,但我的编译器必须具有比他们更严格的设置,或者可能是不同版本的编译器。代码应该只是打开一个窗体并显示一些文本。
using namespace System;
using namespace System::Windows::Forms;
using namespace System::Drawing;
public ref class MyForm : Form
{
public:
MyForm ()
{
Text = "Windows Forms Demo";
}
void Main ()
{
Application.Run (gcnew MyForm());
}
protected:
void OnPaint (PaintEventArgs e)
{
e.Graphics.DrawString ("Hello, world", Font,
gcnew SolidBrush (Color.Black), ClientRectangle);
}
}
【问题讨论】:
-
Sorry error is on line "e.Graphics.DrawString" e 被突出显示,它说 Expression must have a class type
-
你的编译器应该给你一些行信息,以及详细的错误信息。尝试使用编译器启用所有警告。
标签: .net c++-cli compiler-errors