Visual c++ C++/CLI包括问题
再次执行一些C++/CLI编码,并遇到问题。在VS2008中工作,如果有任何问题的话 这是我要做的一个模型。实际上,ClassA是GUI,ClassB是GUI需要交互的后端。我试图通过将它们相互传递给对方来让它们访问对方,但我无法正确地使它们进入范围以创建对另一个的引用 如果您有任何意见,我将不胜感激。今天我花了很多时间在网上寻找,这个解决方案让我非常接近,但我仍然会遇到编译错误。我现在得到的是:Visual c++ C++/CLI包括问题,visual-c++,visual-studio-2008,include,c++-cli,Visual C++,Visual Studio 2008,Include,C++ Cli,再次执行一些C++/CLI编码,并遇到问题。在VS2008中工作,如果有任何问题的话 这是我要做的一个模型。实际上,ClassA是GUI,ClassB是GUI需要交互的后端。我试图通过将它们相互传递给对方来让它们访问对方,但我无法正确地使它们进入范围以创建对另一个的引用 如果您有任何意见,我将不胜感激。今天我花了很多时间在网上寻找,这个解决方案让我非常接近,但我仍然会遇到编译错误。我现在得到的是: Error 1 error C2653: 'NameSpaceB' : is not a
Error 1 error C2653: 'NameSpaceB' : is not a class or namespace name c:\users\andy\documents\visual studio 2008\projects\myhello\myhello\A.h 12 myhello
Error 2 error C2143: syntax error : missing ';' before '^' c:\users\andy\documents\visual studio 2008\projects\myhello\myhello\A.h 12 myhello
Error 3 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\users\andy\documents\visual studio 2008\projects\myhello\myhello\A.h 12 myhello
Error 4 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\users\andy\documents\visual studio 2008\projects\myhello\myhello\A.h 12 myhello
Error 5 error C2653: 'NameSpaceA' : is not a class or namespace name c:\users\andy\documents\visual studio 2008\projects\myhello\myhello\B.h 12 myhello
Error 6 error C2143: syntax error : missing ';' before '^' c:\users\andy\documents\visual studio 2008\projects\myhello\myhello\B.h 12 myhello
Error 7 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\users\andy\documents\visual studio 2008\projects\myhello\myhello\B.h 12 myhello
Error 8 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\users\andy\documents\visual studio 2008\projects\myhello\myhello\B.h 12 myhello
这和我在实际项目中遇到的错误是一样的,所以我知道我的配置有些古怪
/*B.h File Contents*/
#ifndef CLASSB_H
#define CLASSB_H
#include "A.h"
删除
#include“A.h”
部分,您将获得金牌。因为B类不使用A(至少在定义中是这样),所以不需要包含。Ugh,循环头文件依赖项。是的,我已经做到了这一点,但我遵循了一些示例,我认为这非常好!CPP只依赖于它们特定的头,然后头会交叉到另一个类,似乎消除了问题。其中大部分内容是根据我阅读的以下教程生成的:我不知道公共引用是什么意思,它是编译器特有的吗?另外,b
成员声明中的^
似乎是错误的,编译器对此表示不满。啊,C++/CLI。好的,这是Windows使用的CLI/CLR版本C++特有的。一开始有点痛,但很相似。我在pastebin上的错误。在当前示例(和我的项目)中,“Class A”仅引用“Class B”的一个实例,但实际上,它们都必须相互引用。我将发布一个新的pastebin,其中显式显示了此内容。@fooOnYou将include替换为forward声明。今天早些时候,我曾尝试使用此方法,但在试图弄清楚将语句放置在何处时有些迷茫。我刚才试着把它放在#include所在的位置,放在名称空间(但不是类)内,最后放在类定义内。具体地说,我将文本“classnamespaceb::ClassB;”中的。谢谢,@fooOnYou在名称空间内,在类外。这样做似乎让我更接近,但现在我认为我缺少了一些include或其他内容,因为他们看不到其他名称空间。以下是新的错误: