我有一个具有2个winforms的应用程序:Form1.h和TrackEdit.h。他们都在相同的名称空间(“ParkCleanUp2”)。父窗口调用函数.NET C++
从内Form1中我把这个代码:
ParkCleanUp2::TrackEdit^ te;
如果它给了我这些错误:
Error 24 error C2039: 'TrackEdit' : is not a member of 'ParkCleanUp2' (TrackEdit.cpp) c:\users\-joey\documents\visual studio 2010\projects\park cleanup 2\park cleanup 2\Form1.h 2332
Error 25 error C2065: 'TrackEdit' : undeclared identifier (TrackEdit.cpp) c:\users\-joey\documents\visual studio 2010\projects\park cleanup 2\park cleanup 2\Form1.h 2332
Error 26 error C2065: 'te' : undeclared identifier (TrackEdit.cpp) c:\users\-joey\documents\visual studio 2010\projects\park cleanup 2\park cleanup 2\Form1.h 2332
不过,如果我去TrackEdit.h它告诉我:
namespace ParkCleanUp2 {
//Some namespae includes
public ref class TrackEdit : public System::Windows::Forms::Form
所以我想知道为什么它给了我错误“'TrackEdit':不是'ParkCleanUp 2'“以及为什么它正在查看TrackEdit.cpp文件,而我包含.h文件。 我发现很奇怪,也许很重要的一点是,当我评论TrackEdit.h中的#include "Form1.h
行时,它完美无缺,但在TrackEdit.h中,我无法调用Form1的函数(如选中一个列表框),我想实现。
你能告诉我们你的代码呢? – antonijn
我唯一能猜到的是你已经使用了'ParkCleanUp2.TrackEdit'而不是'ParkCleanup2 :: TrackEdit',这是真的吗? – antonijn
@AntonieBlom这是我目前用来运行表单的代码: ParkCleanUp2 :: TrackEdit^te = gcnew ParkCleanUp2 :: TrackEdit(TrackUIDs [track_list-> SelectedIndex]); > ShowDialog(); 虽然,这一个给我的''TrackEdit':不是'ParkCleanUp2''错误的成员,如果我删除了“ParkCleanUp2 ::”命名空间前缀错误消失了,但其他的仍然存在。所以如果我使用这个代码: TrackEdit^te = gcnew TrackEdit(TrackUIDs [track_list-> SelectedIndex]); > ShowDialog(); 第一个错误是固定的,但其他错误仍然存在。 – LeopardGL