Day01 Help
Day01 Help
Agenda
Language Fundamentals
Introduction to CPP
OOP Concepts
Hello World
Data types
Structure in C++
Inline Functions
Classfication of languages:
1. Machine level languages Binary language( 1, 0 )
2. Low level languages Assembly
3. High level languages C, C++, java
Chracteristics of Language
1. It has own syntax
2. It has its own rule(semantics)
3. It contain tokens:
1. Identifier
2. Keyword
3. Constant/literal
4. Operator
5. Seperator / punctuators
4. It contains built in features.
5. We use language to develop application( CUI, GUI, Library )
6. If we want to implement business logic then we should use language.
ANSI
Histroy of C++
Inventor of C++ is Bjarne Stroustrup.
C++ is derived from C and simula.
Its initial name was "C With Classes".
It was developed in "AT&T Bell Lab" in 1979.
It was developed on Unix Operating System.
Standardizing C++ is a job of ANSI.
In 1983 ANSI renamed "C With Classes" to C++.
C++ is objet orieted programming language.
In C++ we can develop code using Procedure as well as object orieneted fashion. Hence it is also called
Hybrid programming language.
C++ Standards
In 1985, the first edition of The C++ Programming Language was released.
In 1989, C++ 2.0 was released. New features in 2.0 included multiple inheritance, abstract classes, static
member functions, const member functions, and protected members.Later feature additions included
templates, exceptions, namespaces, new casts, and a Boolean type.
In 1998, C++98 was released, standardizing the language, and a minor update (C++03) was released in
2003.
After C++98, C++ evolved relatively slowly until, in 2011, the C++11 standard was released, adding
numerous new features,enlarging the standard library further, and providing more facilities to C++
programmers.
A minor C++14 update was released in December 2014.
A major revision where various new additions were introduced in C++17.
Year and version of cpp
1. 1998 : C++98
2. 2003 : C++03
3. 2011 : C++11
4. 2014 : C++14
5. 2017 : C++17
6. 2020 : C++20
The errors generated and hidden errors may reach an astonishing degree, this is not something that
can be solved in the programming stage.
Need to standardize the entire software development process and clarify the software
The tasks of each stage in the development process, while ensuring the correctness of the work of the
previous stage, proceed to the next stage work.
This is the problem that software engineering needs to study and solve.
Object-oriented software development and engineering include the following parts:
Object-oriented programming
OOPS is not a syntax. It is a process / programming methodology which is used to solve real world
problems.
It is invented by Dr. Alan Kay. He is inventor of Simula too.
Unified Modelling Language( UML ) is invented by Grady Booch. If we want to do OOA and OOD then
we can use UML.
According Grady Booch there are 4 main/major and 3 minor elements/parts/pillars of OOPS
1. Abstraction
2. Encapsulation
3. Modularity
4. Hierarchy
1. Typing
2. Concurrency
3. Persistence
Here, word major means, language without any one of the above feature will not be Object orieneted.
Here word minor means, above features are useful but not essential to classify language object
oriented.
Abstraction
Getting only essential things and hiding unnecessary details is called as abstraction.
Abstraction always describe outer behavior of object.
In console application when we give call to function in to the main function , it represents the
abstraction
Encapsulation
Binding of data and code together is called as encapsulation.
Implementation of abstraction is called encapsulation.
Encapsulation always describe inner behavior of object
Function call is abstraction
Function definition is encapsulation.
Modularity
Dividing programs into small modules for the purpose of simplicity is called modularity.
Hirerachy
Level / order / ranking of abstraction is called hireracy.
Its main purpose is to achive reusability.
Advantages of reusability:
Types of Hierarcy:
1. Has-a/Part-of Association/Containment
2. Is-a/Kind-of Inheritance/Generalization
3. Use-a Dependancy
4. Creates-a Instantiation
Typing/Polyorphism
polymorphism = poly(many) + morphism(forms)
An ability of object to take multiple forms is called polymorphism.
Main purpose of polymorphism is to reduce maintenance of system.
Types of polymoprhism:
Concurrency
In context of OS it is called multitasking
Process of executing multiple task simultaneously is called concurrency.
If we want to utilize hardware resources efficiently then we should use concurrency.
Using multithreading, we can achive concurrency.
Persistance
It is the process of maintaing state of object on secondry storage(HDD).
We can achive it using file handling and database programming.
Installation
To install the gcc/g++ compiler use the below link
https://sourceforge.net/projects/tdm-gcc/
https://code.visualstudio.com/download
Hello World
// header file
#include <iostream>
g++ demo01.cpp
a.exe
1. Preprocessor
This is the first stage of any C/C++ program execution process; in this stage Preprocessor
processes the program before compilation. Preprocessor include header files, expand the
Macros.
2. Compiler
This is the second stage of any C/C++ program execution process, in this stage generated
output file after preprocessing ( with source code) will be passed to the compiler for compilation.
Complier will compile the program, checks the errors and generates the object file (this object
file contains assembly code).
3. Linker
It will link the multiple files
4. Loader
It will load the executable for the execution
We can view the intermediate files like preprocesssed (.i),assembly (.asm) file for out .cpp using below
commands
we can view the .i and .asm files but we cannot view the object .o and executable .exe files
1. Array
2. Function
3. Pointer
4. Reference
5. Union
6. Structure
7. Class
Type Modifiers
C++ allows the char, int, and double data types to have modifiers preceding them.
A modifier is used to alter the meaning of the base type so that it more precisely fits the needs of
various situations.
The data type modifiers are
1. short
2. long
3. signed
4. unsigned
The modifiers signed, unsigned, long, and short can be applied to integer base types. In addition,
signed and unsigned can be applied to char, and long can be applied to double.
The modifiers signed and unsigned can also be used as prefix to long or short modifiers. For example,
unsigned long int.
Prepared By : Rohan Paramane 7/8
Day01_Help.MD Sunbeam Infotech 2024-08-26
Type Qualifiers
The type qualifiers provide additional information about the variables they precede.
their are two qualifiers
1. const
2. volatile
Bool Datatype
it can take true or false value.
It takes one byte in memory.
by default the value is false
wchar_t Datatype
wchar_t stands for Wide Character.
This should be avoided because its size is implementation defined and not reliable.
It is similar to char data type, except that it take up twice the space and can take on much larger values.
As char can take 256 values which corresponds to entries in the ASCII table. On the other hand, wide
char can take on 65536 values which corresponds to UNICODE values which is a recent international
standard which allows for the encoding of characters for virtually all languages and commonly used
symbols.
The type for character constants is char, the type for wide character is wchar_t. This data type occupies
2 or 4 bytes depending on the compiler being used. Mostly the wchar_t datatype is used when
international languages like Japanese are used. This data type occupies 2 or 4 bytes depending on the
compiler being used. L is the prefix for wide character literals and wide-character string literals which
tells the compiler that that the char or string is of type wide-char.