指针或变量
pointer or variable?
最近,我正在学习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或&rect (CRect rect)作为参数。这是惊人的!
我想知道一些关于struct base类的规则。谢谢你!在c++中,除了在继承和成员访问级别方面的默认行为外,类和结构是相同的。
c++类默认继承= private成员变量和函数的默认访问级别= private
c++结构默认继承= public成员变量和函数的默认访问级别= public
简而言之,class可以继承c++中的struct。
相关文章:
- 将地址分配给本地指针后,公共对象的变量将消失
- 如果非动态变量被指针引用,何时超出范围?
- 在函数结束后使用指向变量的指针是否安全?
- 有没有将变量名称转换为双指针的简短方法?
- 成员变量指针的函数参数包
- C++ - 使用变量指针调用函数
- 如何返回值为NULL的变量指针
- 在编译时以增量方式构建变量指针的向量
- C 取消实例变量指针
- 每个方法调用上都覆盖了本地变量指针
- 决定对基类的变量指针进行函数调用
- 使用 valgrind 时获得 int 变量指针的无效读取大小错误
- 变量指针的成员函数未绘制到SDL_Surface?
- 何时使用成员变量指针
- 从成员变量指针返回布尔值
- 指向C#和C++之间接口的变量指针
- c++中指向self的成员变量指针
- 为什么变量指针包含相同数据类型的地址?
- 指向用户定义类型的类的全局变量指针
- C++分配一个变量指针地址