问题相关代码
在WinClass.h中
class Window
{
//......
public:
Window();
Direct direct;
private:
HWND hWnd;
int height;
int width;
}
Window::Window()
:
direct(hWnd, width, height) //问题出在此处,希望能在hWnd赋值后,再进行初始化
{
RECT wr;
wr.left = ......;
wr.right = ......;
wr.top = ......;
wr.bottom = ......;
hWnd = CreateWindow(…wr…); //此处要把wr传入
};
在DirectClass.h中
class Direct
{
friend class Window;
public:
Direct(HWND, int, int);
private:
HWND hWnd; //实际上是想把参数传递到DirectClass内部,实在不行就类中类吧~
int width;
int height;
}
Direct::Direct(HWND hWnd, int width, int height)
:
hWnd(hWnd),
width(width),
height(height)
{}
我想要达到的结果
将 Window类 中的hWnd(处理后)、width、height传入Direct类
即
Window | Direct | |
---|---|---|
hWnd | hWnd(CreateWindow(wr)) | hWnd |
height | 不处理 | width |
height | 不处理 | height |