#include
class animal
{
public:
animal()
{
cout<<"animal construct"<
}
~animal()
{
cout<<"construct animal"<
}
virtual void breath() //virtual defines virtual function
{
cout<<"bubble2"<
}
};
class fish:public animal //Only call animal() in animal
{
public:
fish()
{
// cout<<"hello world"<
}
~fish()
{
// cout<<"construct helllo world"<
Keywords:C++
Reference address:C++ subclass overrides base class and virtual processing
}
void breath()
{
//animal::breath();
//cout<<"fish bubble"<
}
};
void fn(animal *pan)
{
pan->breath();
}
void main()
{
fish fh;
//st.breath ();//If the subclass and the base class have two functions with the same name , the subclass will eventually overwrite the base class, which is called overloading.
animal *pan;
pan=&fh; //Change the pointer and replace the pointer of animal with fish. But it still outputs animal. If virtual is added before animal, it will output fish
fn(pan);
}
Previous article:Serial communication between microcontroller and host computer
Next article:How to create header files in C++
Recommended ReadingLatest update time:2024-11-16 20:30
Research on the setting and application of 80C51 reset flag bit
introduction
Setting the reset flag bit is convenient for distinguishing resets caused by different reasons. As a new technology, it is adopted by more and more new microcontrollers. For example, the P87LPC700 and P89LPC900 series of Philips Company, the MC68HC05 series and MC68HC08 series of Freescale Company (fo
[Microcontroller]
ROHM's BD8758xYx-C operational amplifier achieves outstanding performance in four types of noise immunity tests
ROHM develops operational amplifier "BD8758xYx-C" that achieves excellent performance in four types of noise immunity tests
The EMARMOUR™ Series has the strongest anti-interference performance, which helps reduce the design time of abnormality detection systems and improve reliability
ROH
[Analog Electronics]
PT100 temperature detection system based on AT89C51 microcontroller
1. System Overview The modules used in the system include AT89C51 microcontroller + 8-bit common cathode digital tube + ADC0804 analog-to-digital conversion + PT100 temperature detection. The system uses AT89C51 microcontroller as the main control, and uses PT100 to detect the temperature. The detected temperature a
[Microcontroller]
Design of network coordinator based on CC2420 radio frequency chip and S3C2440 chip
1 Overview There are various wireless communication methods. Compared with Bluetooth, Wi-Fi, and GSM mobile communication methods, the ZigBee method developed by the ZigBee Alliance has the advantages of low power consumption, reliable data transmission, good compatibility, low implementation cost, and convenient netw
[Microcontroller]
Suspected iPhone 12 USB-C to Lightning braided cable exposed again
Rumor has it that Apple's upcoming iPhone 12 models will come with a new USB-C to Lightning cable, and the biggest feature of this new charging cable is its braided fabric design. Today, Twitter whistleblower @Mr White shared new pictures. The photo clearly shows that the new charging cable has a braided design, rat
[Mobile phone portable]
C language programming of 8051 microcontroller
8051 C programming is similar to traditional C programming. Of course, some data types are different. As we know, 8051 supports powerful bit addressing capabilities, so 8051 C programming adds some new data types to avoid wasting the capabilities of 8051. The following are the newly added data types. bi
[Microcontroller]
pic12C508 ultrasonic rangefinder program
; Ultrasonic rangefinder ; Internal Osc, WDT Enab LED include p12c508.inc loop equ 10h dly CTR equ 11h tone_cnt equ 12h ; reflection period count period equ 13h ; tmr0 overflow time org 0 MOVwf OS CC AL MOVlw b'10001001' option ;1:2 WDT
[Microcontroller]
Design of Gas Leakage Alarm Based on AT89C51
0 Introduction
With the popularization of urban pipeline and bottled gas, gas leakage, explosion or poisoning accidents caused by improper use and aging equipment occur from time to time, so the installation of gas alarms has received more and more attention. However, the development of gas alarms is very unbalance
[Microcontroller]
Recommended Content
Latest Microcontroller Articles
He Limin Column
Microcontroller and Embedded Systems Bible
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
MoreSelected Circuit Diagrams
MorePopular Articles
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
MoreDaily News
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
Guess you like
- Programming examples to learn DSP timer and interrupt system
- TI Battery Tester Reference Design for High Current Applications
- [ESK32-360 Review] + TFT screen display function and expansion (1)
- [NXP Rapid IoT Review] Part 2: Detailed tutorial of online IDE - Open Rapid IoT to see the weather...
- 【GD32L233C-START Review】3. Implementation of USB keyboard
- Master the wireless communication signal transmission model in one article
- Oscilloscope Travel Guide Higher bandwidth, lower noise, more channels. Let's go on a spontaneous trip with Xiaotai!
- What is the secret to keep your spectrum analyzer from getting sick?
- Share a TI Da Vinci series support website
- FPGA Simplified Design Method Case 4