我绝对处于绝望的境地......使用 C++,我已经定义了这两个类:
// Console.hpp
#ifndef CLASS_Console
#define CLASS_Console
#include <iostream>
#include "Window.hpp"
class Console
{
public:
Window *Win;
Console(Windows *Win); // Which then does "this->Win = Win;"
void AppendText(std::string);
// And some more dozens functions
};
#endif
// Window.hpp
#ifndef CLASS_Window
#define CLASS_Window
#include <iostream>
#include "Size.hpp"
class Window
{
private:
Console *m_Console;
public:
Window(); // Which then does "m_Console = new Console(this); m_Console->AppendText("YEAH");"
Console *getConsole(); // For use by another classes
Size getSize();
// And some more Tens and Tens of functions
};
#endif
一开始,有人会说:“使用前向声明!”
但是鉴于我需要访问这几十个函数中的一些(以一种方式和另一种方式),有什么方法可以避免使用前向声明?
感谢您的(未来)答案!