• 2024-04-24深度解读《深度探索C++对象模型》之C++虚函数实现分析(二)
    接下来我将持续更新“深度解读《深度探索C++对象模型》”系列,敬请期待,欢迎关注!也可以关注公众号:iShare爱分享,自动获得推文和全部的文章列表。第一篇请从这里阅读:深度解读《深度探索C++对象模型》之C++虚函数实现分析(一)这一篇主要讲解多重继承情况下的虚函数实现分析。在多重
  • 2024-04-07C++核心编程:多继承
    #include<iostream>usingnamespacestd;//多继承语法继承方式父类1,继承方式父类2//实际开发过程中,一般不建议使用多继承classBase1{public: Base1() { m_A=100; } intm_A;};classBase2{public: Base2() { m_A=200; } intm_A;};cl
  • 2024-03-20C++ 多重继承下的内存布局
    1.多重继承多重继承示例代码如下:classBase1{public:voidf0(){}virtualvoidf1(){}inta;};classBase2{public:virtualvoidf2(){}intb;};classDerived:publicBase1,publicBase2{public:voidd(){}voidf2(){}
  • 2024-03-06C++派生类构造函数
    实例#include<iostream>usingnamespacestd;classBase1{//基类Base1,构造函数有参数public:Base1(inti){cout<<"ConstructingBase1"<<i<<endl;}};classBase2{//基类Base2,构造函数有参数public:Base2(intj){cout<&l
  • 2023-08-13Day1 - 2023/08/13
    B-BaseK(atcoder.jp)题意:给你两个$K$进制数$A$和$B$,将其转化为十进制,并输出二者的乘积。思路:低位往高位的权重依次为$K^0,K^1,\cdot\cdot\cdotK^n$,若这一位是$1$,就把权重累加起来,最后计算乘积即可。代码:#include<bits/stdc++.h>#defineL(i,j,
  • 2023-04-19多态性4
    #include<iostream>usingnamespacestd;classBase1{ public: virtualvoiddisplay()const;};voidBase1::display()const{ cout<<"Base1::display()"<<endl;}classBase2:publicBase1{ public: voiddisplay()const;};voidBase2::displ
  • 2023-04-12类的继承3
    #include<iostream>usingnamespacestd;classBase1{ public: intvar; voidfun() { cout<<"MembberofBase1"<<endl; } };classBase2{ public: intvar; voidfun(){ cout<<"MemberofBase2"<<endl; }};
  • 2023-04-12类的继承2
    #include<iostream>usingnamespacestd;classBase1{ public: Base1(inti){ cout<<"ConstructingBase1"<<i<<endl; } Base1(){ cout<<"ConstructingBase1"<<endl; }};classBase2{ public: Base2(intj
  • 2023-04-12类的继承1
    #include<iostream>usingnamespacestd;classBase1{ public: Base1(inti){ cout<<"ConstructingBase1"<<i<<endl; }};classBase2{ public: Base2(intj){ cout<<"ConstructingBase2"<<j<<endl;
  • 2023-04-10打卡一小时
    #include<iostream>#include<cmath>#include"Rectangle.h"usingnamespacestd;intmain(){   Rectanglerect;   rect.intiRectangle(2,3,20,10);   rect.move(3,2);   cout<<"Thedateofrect(x,y,w,h):"<&l