我想知道是否有任何给定的函数允许我内省一个类而不必编写包含类的包.
例如,我想看一下Integer类的方法和超类,为了做到这一点,我必须指定类所在的包.这将是"java.lang.Integer"
而不是这样做,我只想输入类名,以便显示类的信息.就像这个"整数"
我怎么能让我的程序只检查类名,无论它位于何处?
这是我的两个类,Node和DobleNode,它们都在不同的.h文件中,并且它们都有自己的.cpp文件.
//"Node.h"
class Node
{
public:
Node(string pName, string pID);
void setReferencia(DobleNode *pReferencia);
DobleNode* getReferencia(void);
private:
string Name;
string ID;
DobleNode *referencia;
};
//"DobleNode.h"
class DobleNode
{
public:
DobleNode(string pBank_code, string pCard_type);
void setReferencia(Node *pReferencia);
Node* getReferencia(void);
private:
string bank_code;
string card_type;
Node *referencia;
};
Run Code Online (Sandbox Code Playgroud)
问题是我需要一个参考.在类Node中,必须存在DobleNode类型的属性,并且在类DobleNode中必须存在Node类型的属性.它似乎非常简单,我只需要在"Node.h"之前加入"DobleNode.h",一切都会正常工作......
但是,如果我这样做,稍后,当我尝试编译我的小程序时,它表示标识符Node不存在.如果我以另一种方式执行,它会说同样的事情,但这次标识符DobleNode是不存在的标识符.
我怎么能解决这个问题,我认为解决方案可能是将两个类放在同一个文件中,但我认为有更好的解决方法.有没有办法"告诉"编译器同时检查"Node.h"和"DobleNode.h",还是什么?
感谢您的回答.
顺便说一下,我正在研究Visual Studio 2010 Proffesional,C++(很明显).