0% found this document useful (0 votes)
4 views8 pages

C++

The document provides an overview of C++ programming concepts including data abstraction, variables, data types, and memory management. It explains the importance of statements, modifiers, floating-point precision, and the use of pointers, as well as dynamic memory allocation. Additionally, it covers flow control structures, manipulators, and the memory map structure during program execution.

Uploaded by

Lutetium Emon
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views8 pages

C++

The document provides an overview of C++ programming concepts including data abstraction, variables, data types, and memory management. It explains the importance of statements, modifiers, floating-point precision, and the use of pointers, as well as dynamic memory allocation. Additionally, it covers flow control structures, manipulators, and the memory map structure during program execution.

Uploaded by

Lutetium Emon
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
You are on page 1/ 8

“C++: 31 hours long video of freecodecamp”

Features:
supports data abstruction, means Data abstraction is a fundamental concept in
computer science and software engineering that involves hiding the
implementation details of data types and exposing only the essential features
or behaviors to the outside world. Data abstraction is a powerful concept that
facilitates the design, implementation, and maintenance of complex software
systems by providing clear interfaces, encapsulating implementation details,
promoting modularity, and supporting information hiding.
-----------------------------

Statement: A statement is a basic unit of computation in a C++ program. Ends with a


semicolon(;).
They are executed from top to bottom when program is run.
------------------------

-----------------------------------------
input For Space separated word

Variable: A piece of memory that used to store specific type of data.

Number System representation:

*** Modifier like signed, unsigned used integral data type as decimal number/ whole number.
Can’t use for float, double(2.0, 2.5).
Float and Double:
**Precision includes digits before decimal point(.). 12547.325-> 12547 included in the
precision.
For Float: 12345.6789-> 89will be garbage value. Cause precision 7 for Float. May print like:
12345.6725
** float a=123456789-> 89 will b garbage value. May print like: 12345.6745

Floatiing point number memory representation is not similar to deciaml number. It explained in
IEEE_754 -> IEEE_754-> Press ctrl &Click

cout<<setprecision(20);
used for set precision. Library> #include<iomanip>
suffixes(like f, L): u // unsigned
ul // unsigned long
ll // long long
-------------------------------------xxx--------------------------------
**Booleans occupy 1byte/8bits in memory.
bool x=true;
bool y=false;
cout<<boolalpha; //used for printf true/false instead of 0/1
cout<<x<<” ”<<y;
will print true, false.
----------------------------------------
Character:

------------------------------

** 31/10 means how many times 10 is gonna fit in 31. so ans is 3.


* Relation Operator: > ,< , >=, <=
* Logical Operator: &&, ||, !
------------------------
Manipulator: https://en.cppreference.com/w/cpp/io/manip //for more

* std:flush: when we print something, it does not go directly to the terminal. It store somewhere
called “buffer”. When buffer is full/ complete it goes to terminal. If use std:flush data directly goes
to console/terminal instead of goes to buffer.
*setw() : set width
cout<<right; // printf from right. Left for left alinement

cout<<setfill(‘-’) // blank space fill with ‘-’


*for finding max min numeric number limits data type can hold.
Need this> #include<limits>
https://en.cppreference.com/w/cpp/types/numeric_limits

--------------------------
#include<cmath> : abs(), pow(), ceil(), log(), sqrt(), sin(), tan() etc
https://en.cppreference.com/w/cpp/header/cmath
for log(): log(10) means loge(10). So have to fix the base as log10(10). E=2.71..
* round(): 3.5 will make 4, and 3.49 will make 3.
-------------------------------

if we take data type less than 4 byte and perform arithmatic operation compiler
automatically convert it to 4 byte. This behavior also present on other operator like bitwise
operator.(>>, <<)
-----------------
flow control: if else, switch, ternary operator.
*Switch: if we not use “Break”, the case which match, after that all case will execute and
print every case value.
*we can use int, char , double, enum etc but not string as case.
--------------------------------------
*if we use “const” before array. We cant modify array elements.
*a[ ]={2,3,7,5,2,3}; size(a) return the size of array. /Or sizeof(a)/sizeof(a[0]);

Pointer

Pointer is special kind of variable.


int* int_num{}; or int* int_num; // will point to a integer type variable //initialise with null
// pointer(nulptr)
double* frac_num{}; // will point to a double type variable
int * int_num{}; // this initialisation with {} is going to initialise with special address means
it is not //pointing any variable
int * int_num{nullptr}; // this pointer not pointer anywhere
** pointer of int, double, char etc all are same size. Cause they only store address.
Dereferencing pointer: reading something(value) on the address of the pointer.
Cout<<*ptr;
string with pointer: char* p_msg= “Hello World!”; // the pointer will point to the 1 st
character of string
*this will compile with warning. Use const char* p_msg= “Hello World!”;
printf p_msg will print whole string. But using dereferencing will print 1 st
character(*p_msg).
*** without const it gives warning/refuse to compile cause compiler is going to convert
string into char array of constant char. What we are using is points to that is not a const
char pointer. So pointer here might be used to try or modify data. That’s why it refuse
unless using const.
Check at 10:17min

Memory Map
When we run a program it runs on RAM. Verious program of OS or other is running on
memory.

This process thinks it own 0~2N amount of memory which is virtual memory.
When we run a program it is going to go through a PCU section called memory
management unit(MMU).

Part that are likely not to be used are discarded from the RAM.
MMU realy does is, helps us mapping between the memory map in ur program and the real
thing we have in RAM.
If we run few program, they are going to go through MMU and MMU is going assign them
real section on RAM
* Since program thinks it 2n -1memory, The MMU is going to transform between the idea
the program has and the RAM we have(assigned memory by MMU).
* The memory map/Structure of program is standard format defined by OS. Thats why we
cant run directly window program on Linux.
*Memory map is divided into a lot parts
* STACK: Local variable stores on stack section.
* print, statement, function others store on stack section.
* TEXT:Actual binary load on Text so that CPU can execute it.
* HEAP:Additional memory when we run out of stack memory also to make things better
for program, Used for run time.

Dynamic Memory Allocation


2nd point- full Control: when declare a variable a=23; in stack it remove when scope is
over. Developer doesn’t have full control. But in heap developer have full control when a
variable comes to work and dies. >> 10:41 min

*set up a pointer which point to heap memory.


After initializing a pointer with nullptr. When p_number4=new int execute the OS is
allocate a memory on heap

You might also like