首页 > 其他分享 >打卡第二天

打卡第二天

时间:2023-04-13 20:45:42浏览次数:27  
标签:cout int Object 第二天 打卡 Document public name

7-7

#include <iostream>

#include<string>

using namespace std;

class Document{  

private:

    string name;

public:

    Document(string nam):name(nam) 

    {

        cout<<"Name:"<<name<<endl;

    }

    ~Document(){}  

};

class Book:public Document{ 

private:

    int pageCount;

public:

    Book(string nam,int ag):Document(nam),pageCount(ag) 

    {

 

        cout<<"Page:"<<pageCount<<endl;

    }

    ~Book(){}

};

int main()

{

    int page;

    string name;

    cout<<"Input Name and Page:";

    cin>>name>>page;   

    Book b(name,page); 

    return 0;

}

7-9

#include  <iostream>

#include  <string>

using  namespace  std;

class  Object

{

public:

        Object()

        {

                cout<<"Constructing  Object!"<<endl;

        }

        ~Object()

        {

                cout<<"Destructing  Object!"<<endl;

        }

        void  getInfo()

        {

                cout<<"Input  weight:";

                cin>>weight;

        }

        void  showInfo()//类Object的成员函数

        {

                cout<<"Weight:"<<weight<<endl;

        }

private:

        int  weight;

};

class Box:public Object{

private:

    int height;

    int width;

public:

    Box()

    {

        cout<<"Constructing Box!"<<endl;

    }

    ~Box()

    {

        cout<<"Destructing Box!"<<endl;

    }

 

    void  getInfo()

    {

        Object::getInfo();

        cout<<"Input height and width:";

        cin>>height>>width;

    }

 

    void  showInfo()

        {

            Object::showInfo();

                cout<<"Height and width:"<<height<<","<<width<<endl;

        }

};

 

int  main()

{

        Box  box;

        box.getInfo();

        box.showInfo();

        return  0;

}

标签:cout,int,Object,第二天,打卡,Document,public,name
From: https://www.cnblogs.com/xscya/p/17316345.html

相关文章

  • 每日打卡-4.1
    一.问题描述定义计数器Counter类,对其重载运算符+二.设计思路设计counter类,包含属性i,然后重载运算符+,使其能够使两个counter类对象相加,返回一个counter类对象。三.流程图  四.伪代码 五.代码实现 #include<iostream>usingnamespacestd;classcounter......
  • 最新版人脸识别小程序 图片识别 生成码签到码 地图上选点进行位置签到 计算签到距离
    技术选型1,前端小程序原生MINA框架cssJavaScriptWxml2,管理后台云开发Cms内容管理系统web网页3,数据后台小程序云开发云函数云开发数据库(基于MongoDB)云存储4,人脸识别算法基于百度智能云实现人脸识别一,用户端效果图预览老规矩我们先来看效果图,如果效果图符合你的需求,就继续往下......
  • 第二天第四个问题
    问题描述:编写一个使用嵌套循环的程序,要求用户输入一个值,指出要显示多少行。然后程序将显示相应行数的星号,其中第一行包括一个星号,第二行包括两个星号,依次类推。每一行包含的字符数等于用户指定的行数,在星号不够的情况下,在星号前面加上句点。运行情况如下:enternumberofrows:5.......
  • 第二天第三个问题
    问题描述:编写上一个问题,但使用string对象而不是字符数组解决思路:于上个问题相同代码:#include<iostream>#include<cstring>#include<string>usingnamespacestd;intmain(){ stringa; stringb="done"; intans=0; cout<<"enterwords:"; cout<&......
  • 第二天打卡第二个问题
    问题描述:编写一个程序,它使用一个char数组和循环来每次读取一个单词,直到用户输入done为止。随后,该程序指出用户输入了多少个单词不包括done在内。下面是运行状况enterwords:anteaterbirthdaycategorydumpsterenvyfinaglegeometrydoneforsureyouenteredatotalof7......
  • c++打卡第四天
    一、题目描述。  实现一个简单的程序,运行时显示“Menu:A(dd) D(elete)S(ort)Q(uit),Selectone:"提示用户输入,A代表增加,D表示删除,S表示排序,Q代表推出,输入为ASD时分别提示“数据已经增加、删除、排序。”输入为Q时程序结束。①要求用ifelse语句判断,用breakcontinue控......
  • 打卡4.13
    #include<iostream>usingnamespacestd;classTime{public:      Time();      friendvoiddisplay();private:      inthour,minu,sec;};Time::Time(){     hour=11;      minu=11;      sec=11;}voiddisplay(){Tim......
  • 打卡2
    #include<stdio.h>intmain(){  inta,b,c,i=0;  printf("A,B,C三人所选的书号为:\n");  for(a=1;a<=5;a++)    for(b=1;b<=5;b++)      for(c=1;c<=5;c++)        if(a!=b&&b!=c&&a!=c){          pri......
  • 七天玩转Redis |第二天打卡 学习Redis的基本数据类型
    今天学习的内容是Redis的五种数据类型今天的收获是Redis与我们常用的数据库不同,数据类型只有五种String、Hash、List、Set、ZSet。这五种类型比较陌生的应该是ZSet类型、ZSet类型既有Set类型的值唯一,也有List类型的值有序排列。这五种类型我用的最多的是String、List、Hash......
  • 七天玩转Redis | 打卡第三天 使用Redis的地理位置、基数统计、位图场景
    今天学习的内容今天学习了Redis在地理位置、基数统计、位图场景上的使用今天的收获今天的收获,了解了Redis在另外几个场景下的应用,比如说地理位置长的应用,在以前我只知道用一些特殊的api来计算距离,没想到Redis还提供这样的服务,这样可以省去调用一些api来计算,可以直接将要计......