当前位置:网站首页>Experiment 3 inheritance and derived classes
Experiment 3 inheritance and derived classes
2022-07-19 06:36:00 【A student of programming】
- Experimental purpose or task
Object oriented software development method is a software development method developed by absorbing useful concepts and effective methods in the field of software engineering . It sets abstraction 、 encapsulation 、 Inheritance and polymorphism in one , It can help programmers develop modularity 、 High degree of data abstraction , Reflect information concealment 、 Reusable 、 Easy to modify 、 Easy to transplant and other features of the program .
This course is based on C++ The object-oriented mechanism in the language is mainly , Discuss the basic idea and method mechanism of object-oriented programming . Through the experimental teaching link , Enable learners to pass a certain amount of program examples and related exercises in the learning process , Gradually master C++ Process oriented and object-oriented functions , So as to master the basic knowledge and skills of object-oriented programming .
Through this experimental teaching link , It can improve learners' professional ability in the following aspects :
- Improve learners' abstract ability and logical thinking ability to solve problems ;
- Preliminarily master the object-oriented software design ideas ;
- Improve learners' self-learning ability of object-oriented program development tools ;
- Make learners have the basic literacy of object-oriented program development .
- Basic requirements of experimental teaching
- Understand and master C++ Advanced features of language functions , Understand the data abstraction and data encapsulation of object-oriented programming , master C++ The mechanism and method of data encapsulation and information hiding through classes and objects ;
- Understand the design idea of object-oriented programming code reuse , master C++ Class inheritance and derivation mechanism and implementation approach ;
- Understand the concept and idea of polymorphism in object-oriented programming , master C++ Operation overload 、 function overloading 、 The mechanism and method of realizing polymorphism by virtual function Technology ;
- Understand and master C++ I/O The idea and method of device independence of stream to realize input and output .
- Inheritance and derived classes
#include<iostream>
#include<string>
#include<stdlib.h>
using namespace std;
class Building
{
public:
void Buildings(string address, int housenum)
{
address = address;
housenum = housenum;
}
public:
string address;
int housenum;
};
class House:public Building
{
public:
void Houses(Building b,int roomnum, int area)
{
this->address = b.address;
this->housenum = b.housenum;
roomnum = roomnum;
area = area;
}
void printfout()
{
cout <<" The address is :"<< address << endl;
cout <<" Building No :"<<housenum << endl;
cout <<" room number :"<<roomnum << endl;
cout <<" area :"<<area <<" Square meters "<< endl;
}
public:
int roomnum;
int area;
};
class Office:public Building
{
public:
void Offices(Building b,string officename, string telnum)
{
this->address = b.address;
this->housenum = b.housenum;
officename = officename;
telnum = telnum;
}
void printfout()
{
cout <<" The address is :"<< address << endl;
cout <<" Building No :"<<housenum << endl;
cout << " Office name :" << officename << endl;
cout << " Phone number :" << telnum << endl;
}
public:
string officename;
string telnum;
};
int main()
{
Building building;
House house;
Office office;
building.Buildings(" Shaanxi University of science and technology ", 300);
house.Houses(building,413,200);
house.printfout();
office.Offices(building," The office ","83621");
office.printfout();
return 0;
}边栏推荐
- 实验四 运算符重载和虚函数
- Experiment 1 simple program design
- 实验一 简单程序设计
- Learning non posture gaze deviation with head movement
- Antd is not defined
- Peerless good problem (bit operation optimization DP)
- Make config analysis of configuration commands before uboot compilation
- Typescript learning
- LeetCode树
- [force buckle] flip binary tree
猜你喜欢

日常的眼睛接触检测使用无监督的注视目标发现

Design and implementation of a gesture control system for tablet computer based on gaze

Daily eye contact detection uses unsupervised gaze target detection

Learning video saliency from human gaze using candidate selection

Restapi implements aggregation (dark horse tutorial)
![[force buckle] symmetric binary tree](/img/a4/31e936fb242aa8a3243ea257f5fd29.png)
[force buckle] symmetric binary tree

Antd is not defined

自下而上和自上而下的注意力:不同的过程和重叠的神经系统 2014sci

Attention prediction in self video based on motion and visual prominence

吴恩达机器学习第12-13章
随机推荐
日常的眼睛接触检测使用无监督的注视目标发现
SeaChest Utilities 工具,让你的硬盘功耗又低又长寿
Learning non posture gaze deviation with head movement
工作中遇到的一些问题
[force buckle] ring list II
Talking about several solutions of cross domain
Decorate Apple Tree
Bottom up and top-down attention: different processes and overlapping nervous systems 2014sci
无80和443端口下申请域名SSL证书(适用于 acme.sh 和 certbot)
Typescript learning
Make config analysis of configuration commands before uboot compilation
Acwing game 58 (AK)
2022/07/12 learning notes (day05) JS built-in functions
2022/07/09 group 5 Ding Shuai's study notes day02
Single table query, add, update and delete data
Operation of documents in index library
基于运动和视觉突出性的自我视频中的注意预测
Mapping index attribute & operation of creating index
UDP message structure
【力扣】设计循环队列