通过基类的指针在派生类数组中访问派生类引发的越界问题

#include<iostream> class Base { public: int x; }; class Derive : public Base { int y; }; void fun(Base* b) { b[1].x = 1; } int main() { Derive arr[5];
posted @ 2024-03-19 16:44  HJfjfK  阅读(6)  评论(0编辑  收藏  举报