王杰C++day5

cpp 复制代码
#include <iostream>

using namespace std;

class Sing
{
private:
    string sing;
public:
    Sing(){}
    Sing(string s):sing(s)
    {

    }
    void show()
    {
       cout << sing << endl;
    }
};

class Jump
{
private:
    string jump;
public:
    Jump() {}
    Jump(string j):jump(j)
    {}
    void show()
    {
        cout << jump << endl;
    }
};

class Kun:public Sing,public Jump
{
private:
    string rap;
    string basketball;
public:
    Kun(){}
    Kun(string s,string j,string r,string b):Sing(s),Jump(j),rap(r),basketball(b)
    {}
    void show()
    {
        cout << rap << endl;
        cout << basketball << endl;
        cout << "kunkun出场" << endl;
    }
};

int main()
{
    Kun k1("唱","跳","rap","篮球");
    k1.Sing::show();
    k1.Jump::show();
    k1.show();
    return 0;
}
相关推荐
人工智能AI技术5 分钟前
GitHub Copilot 2026新功能实操:C++跨文件上下文感知开发,效率翻倍技巧
c++·人工智能
大志若愚YYZ36 分钟前
ROS2学习 C++中的this指针
c++·学习·算法
玖釉-1 小时前
[Vulkan 学习之路] 16 - 最终章:渲染循环与同步 (Rendering & Presentation)
c++·windows·图形渲染
狗狗学不会1 小时前
Pybind11 封装 RK3588 全流程服务:Python 写逻辑,C++ 跑并发,性能起飞!
c++·人工智能·python·目标检测
DYS_房东的猫1 小时前
《 C++ 零基础入门教程》第10章:C++20 核心特性 —— 编写更现代、更优雅的 C++
java·c++·c++20
Howrun7772 小时前
虚幻引擎_AController_APlayerController_AAIController
开发语言·c++·游戏引擎·虚幻
小林rr2 小时前
深入探索 C++:现代特性、工程实践与性能优化全解
java·c++·性能优化
羊小猪~~2 小时前
【QT】-- QT基础类
开发语言·c++·后端·stm32·单片机·qt
努力写代码的熊大3 小时前
深入探索C++关联容器:Set、Map、Multiset与Multimap的终极指南及底层实现剖析
开发语言·c++
txinyu的博客3 小时前
Linux 内存管理
linux·运维·开发语言·c++