
C++
文章平均质量分 69
白衣剑少
衣上征尘杂酒痕,远游无处不消魂。
此人合是诗人未?细雨骑驴入剑门。
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
C++ 派生类指针与基类指针的转化
`MostDerived` 是 `Derived` 的子类,因此 `Derived*` 可以安全访问 `MostDerived` 对象中属于 `Derived` 的部分(除了普通函数,还包括虚表)。- 无论通过 `Base*` 还是 `Derived*` 调用 vFunc()`,实际都会执行 `MostDerived::vFunc()`(因为对象实际类型是 `MostDerived`)。- 在 `MostDerived::foo()` 中,2. `this` 指针的正确性。1. 虚函数动态绑定。原创 2025-07-05 10:52:20 · 352 阅读 · 0 评论 -
C++之enum用法简介
代码:#include <iostream>using namespace std;enum fruit { apple, oringe, banana, watermelonl} myfruit;int main(){ myfruit = banana; switch (myfruit) { case apple: cout << "apple is here.\n"; break; case banana: cout <<原创 2020-10-31 12:26:04 · 715 阅读 · 0 评论 -
C++之virtual虚函数的几种用法
1. virtual functionbase class(virtual ), derived class(override)2. virtual destructor3. pure virtual functionit is Claimed in base class without implementation, and enforce the subclass (derived class) to implement原创 2020-11-04 21:12:45 · 655 阅读 · 0 评论 -
C++之Stack vs Heap
一、预备知识—程序的内存分配一个由C/C++编译的程序占用的内存分为以下几个部分1、栈区(stack)— 由编译器自动分配释放 ,存放函数的参数值,局部变量的值等。其操作方式类似于数据结构中的栈。2、堆区(heap) — 一般由程序员分配释放, 若程序员不释放,程序结束时可能由OS回收 。注意它与数据结构中的堆是两回事,分配方式倒是类似于链表,呵呵。3、全局区(.........原创 2018-11-09 09:18:05 · 185 阅读 · 0 评论 -
C/C++之pointer
Refer to new memory reserved during program executionRefer and share large data structures without making a copy of the structuresTo specify relationship among data-linked lists, trees, graphs...原创 2019-06-11 21:24:09 · 315 阅读 · 0 评论