0 - C++ - Overview
0 - C++ - Overview
0 - C++ - Overview
It was designed to be a simple, efficient, and portable language for developing system software, such as operating systems and compilers.
C is known for its close-to-the-hardware nature, making it suitable for tasks that require direct access to system resources and low-level
memory manipulation.
It provides constructs for low-level programming, such as pointers and manual memory management, giving programmers fine-grained
control over system resources.
C has influenced many other programming languages and is often used as the foundation for developing software in various domains.
C++ Programming Language:
C++ is an extension of the C programming language with added features for object-oriented programming (OOP).
It was developed by Bjarne Stroustrup at Bell Labs in the 1980s as an enhancement to C, adding support for classes, inheritance,
polymorphism, and other OOP concepts.
C++ retains compatibility with C, allowing C++ programs to incorporate C code and vice versa.
In addition to OOP, C++ also supports generic programming through templates, which allow the creation of reusable, type-safe functions
and data structures.
1
0 - C++_Overview
C++ is widely used in various domains, including game development, system programming, embedded systems, and large-scale software
projects.
0.2 - why we need c++
1. Object-Oriented Programming (OOP) Features:
C++ supports OOP concepts such as classes, objects, inheritance, polymorphism, and encapsulation. This allows for the creation of
modular, reusable code that is easier to understand, maintain, and extend. OOP promotes code organization and abstraction, leading to more
scalable and maintainable software.
2. Performance:
C++ offers high performance and efficiency, making it suitable for resource-intensive applications such as games, simulations, real-time
systems, and embedded systems. C++ allows fine-grained control over memory allocation and management, enabling developers to optimize
code for speed and memory usage.
3. Compatibility with C:
C++ is compatible with C, meaning C++ code can incorporate C libraries and vice versa. This interoperability allows developers to
leverage existing C codebases and libraries while taking advantage of C++'s additional features. It also facilitates the gradual transition of legacy
C code to C++.
4. Standard Template Library (STL):
C++ includes the Standard Template Library (STL), which provides a rich collection of generic data structures (such as vectors, lists,
maps, and queues) and algorithms (such as sorting, searching, and manipulation). The STL allows developers to write efficient, type-safe code
without reinventing the wheel, saving time and effort.
5. Flexibility:
C++ is a versatile language that can be used for a wide range of applications, including desktop software, mobile apps, web development
(via frameworks like Qt), game development (using engines like Unreal Engine), system programming, scientific computing, and more. Its
flexibility and scalability make it suitable for both small-scale projects and large-scale enterprise applications.
2
0 - C++_Overview
The compilation process typically involves multiple stages, including lexical analysis, syntax analysis, semantic analysis, optimization,
and code generation.
Once the compilation process is complete, the resulting executable file contains machine code that can be directly executed by the
computer's hardware.
Examples of compiled languages include C, C++, Java (to bytecode), and Rust.
2.Interpreter:
An interpreter is a program that reads and executes source code line by line, translating each line into machine code or executing it
directly.
Instead of translating the entire program upfront, an interpreter processes code on-the-fly, executing each statement sequentially.
Interpreters are often used in scripting languages and languages with dynamic typing, where runtime flexibility is valued over
performance.
3
0 - C++_Overview
While interpreters may provide greater flexibility and interactivity during development, they can be slower than compiled languages
since they don't produce optimized machine code.
4
0 - C++_Overview
5
0 - C++_Overview
C C++
C does no support polymorphism, encapsulation, and inheritance C++ supports polymorphism, encapsulation, and inheritance because
which means that C does not support object oriented programming. it is an object oriented programming language.
Data and functions are separated in C because it is a procedural Data and functions are encapsulated together in form of an object in
programming language. C++.
6
0 - C++_Overview
C C++
Built-in data types is supported in C. Built-in & user-defined data types is supported in C++.
C is a function driven language because C is a procedural C++ is an object driven language because it is an object oriented
programming language. programming.
Function and operator overloading is not supported in C. Function and operator overloading is supported by C++.
Functions in C are not defined inside structures. Functions can be used inside a structure in C++.
Namespace features are not present inside the C. Namespace is used by C++, which avoid name collisions.
7
0 - C++_Overview
C C++
Reference variables are not supported by C. Reference variables are supported by C++.
Virtual and friend functions are not supported by C. Virtual and friend functions are supported by C++.
Instead of focusing on data, C focuses on method or process. C++ focuses on data instead of focusing on method or procedure.
C provides malloc() and calloc() functions for dynamic memory C++ provides new operator for memory allocation and delete
allocation, and free() for memory de-allocation. operator for memory de-allocation.
Direct support for exception handling is not supported by C. Exception handling is supported by C++.
scanf() and printf() functions are used for input/output in C. cin and cout are used for input/output in C++.
8
0 - C++_Overview
C C++
Strict type checking in done in C++. So many programs that run well
There is no strict type checking in C programming language. in C compiler will result in many warnings and errors under C++
compiler.
Named initializers may appear out of order Named initializers must match the data layout of the struct
9
0 - C++_Overview
C C++
10