![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
C&C++ Base_point
学习C++一些基础的知识点
weixin_42734445
这个作者很懒,什么都没留下…
展开
-
dynamic_cast和static_cast
#include <iostream>class F{public: F() {} //virtual ~F() {} virtual void Print() { std::cout << "F::Print()" << std::endl; }};class S : public F{public: S() {} ~S() {} void Print() { std::cout << "S::Print()" <原创 2021-10-09 17:53:04 · 80 阅读 · 0 评论 -
手拿把掐:类对象在进行函数传参及返回临时对象时调用过程分析
#include <iostream>using namespace std;class Person{public: Person() { std::cout << "Person()" << std::endl; } virtual ~Person() { std::cout << "~Person()" << std::endl; } Person(const Person& p) { this原创 2021-09-28 20:11:49 · 115 阅读 · 0 评论 -
四种类型转换的理解
const_cast该操作两句口诀: “常量指针转化为非常量的指针,并且指向原来的对象” “常量引用转化为非常量的引用,并且指向原来的对象”通俗说,该操作会去掉常量属性。例子如下:int value = 1;const int* p = &value; //此处底层const无法修改value的值//*p = 3; //无法修改指向value的值,error C3892: “p”: 不能给常量赋值int* p1 = const_cast<int*>(p);*p..原创 2021-08-30 12:39:48 · 79 阅读 · 0 评论 -
explicit
explicit使用当一个类的构造函数有参数的时候class T{public: /*T() { std::cout << "T()" << std::endl; }*/ T(int a) { std::cout << "T(int a)" << std::endl; std::cout << a << std::endl; }public: //int num_;};在主函数中作如下操作in原创 2021-08-26 14:25:53 · 46 阅读 · 0 评论 -
对于数组的理解
对于数组的理解疑问之处:1.数组名称代表什么?2.对数组名取地址会发生什么?3.数组的偏移结果?验证:数组名就是首元素地址int arr[5] = { 0,1,2,3,4 };printf("相同地址\n");printf("%p\n",arr); //数组名是首元素地址,对其进行*操作,得到首元素printf("%p\n",&arr); //虽然地址相同,但是对数组名取地址得到的却是整块数组地址,printf("%p\n",&arr[0]);printf("地址虽原创 2021-07-01 20:50:20 · 45 阅读 · 0 评论