- Expert C++
- Vardan Grigoryan Shunguang Wu
- 158字
- 2021-06-24 16:34:00
Understanding objects
Most of the time, we operate with a collection of data grouped under a certain name, thus making an abstraction. Variables such as is_military, speed, and seats don't make much sense if they're perceived separately. Grouping them under the name with spaceship changes the way we perceive the data stored in the variables. We now refer to the many variables packed as one single object. To do so, we use abstraction; that is, we collect the individual properties of a real-world object from the perspective of the observer. An abstraction is a key tool in the programmer's toolchain as it allows them to deal with complexity. The C language introduced the struct as a way to aggregate data, as shown in the following code:
struct spaceship {
bool is_military;
int speed;
int seats;
};
Grouping data is somewhat necessary for object-oriented programming. Each group of data is referred to as an object.
- 精通Nginx(第2版)
- 大學(xué)計(jì)算機(jī)基礎(chǔ)(第三版)
- 數(shù)據(jù)庫原理及應(yīng)用(Access版)第3版
- Visual C++串口通信開發(fā)入門與編程實(shí)踐
- Python面向?qū)ο缶幊蹋簶?gòu)建游戲和GUI
- 網(wǎng)站構(gòu)建技術(shù)
- PhoneGap:Beginner's Guide(Third Edition)
- Domain-Driven Design in PHP
- 硬件產(chǎn)品設(shè)計(jì)與開發(fā):從原型到交付
- SignalR:Real-time Application Development(Second Edition)
- 基于GPU加速的計(jì)算機(jī)視覺編程:使用OpenCV和CUDA實(shí)時(shí)處理復(fù)雜圖像數(shù)據(jù)
- Drupal Search Engine Optimization
- Python數(shù)據(jù)預(yù)處理技術(shù)與實(shí)踐
- 情境微課開發(fā)(第2版)
- Python程序設(shè)計(jì)案例教程:從入門到機(jī)器學(xué)習(xí)(微課版)