最近,我學習MFC,以下代碼困擾了我很多:指針或變量?
class CRect : public tagRECT
{
public:
// Constructors
// uninitialized rectangle
CRect();
// from left, top, right, and bottom
CRect(int l, int t, int r, int b);
// copy constructor
CRect(const RECT& srcRect);
// from a pointer to another rect
CRect(LPCRECT lpSrcRect);
// from a point and size
CRect(POINT point, SIZE size);
// from two points
CRect(POINT topLeft, POINT bottomR
...
的基類的CRect的是一個結構!我從來沒有學過這種如果我打電話
CWnd :: GetClientRect(LPRECT lpRect);
我可以使用RECT或&矩形(的CRect RECT)作爲parameter.It的驚人!
我想知道一些有關基類結構的規則。謝謝!
@KirilKirov RECT'是Win32中的'struct' – 2013-03-26 13:05:50
IIRC正確地說,這和'struct base'沒有任何關係。如果你看'CRect',我想你會看到這個方法'運算符LPRECT(){return this; }'這是調用操作符來自動將CRect轉換爲LPRECT的操作符。是的,它是一個巧妙的技巧,幾乎可以在任何時候運行。 – john 2013-03-26 13:06:23