An open API service indexing awesome lists of open source software.

https://github.com/yashlad27/cpp_revision_repo

C++ Revision For DSA
https://github.com/yashlad27/cpp_revision_repo

cpp dsa dsa-practice

Last synced: about 1 year ago
JSON representation

C++ Revision For DSA

Awesome Lists containing this project

README

          

# Cpp_Revision_Repo
-----------------------------------------------------------------------------------------
C++ Basic code syntax, stl library examples and dsa udemy course

## Sequence Containers:
1. Vectors:
-> random access - fast
-> MIDDLE insertion/ deletion - slow
-> insertion/ Deletion at the end - fast

2. List:
-> Random access - slow
-> MIDDLE deletion/ insertion - fast
-> Deletion/ insertion at the end - fast

## Associative Containers:
-> All operations fast except Random Access

## Derived Containers:
-> depends on Data structure.

----------------------------------------------------------------------------------------
# Exception Handling:
## Two Child Classes of Exception Lib:
1. Logic_error:
a logic_error results from a fault in logic in our code.
{out of range error!}
or
{length_error: occurs in situations involving invalid lengths}

2. runtime_error

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

# Pointers:
1. Also called pointer variables.
2. Holds a memory address.
3. Refer to the data of interest indirectly.

## Declaring a pointer:
1. int* myIntPtr {not an integer, its a pointer to an integer}
2. using ptr in the identifier is common practice.

## declaring multiple variables per line:
int *ptr1, *ptr2, *ptr3.

## Three situations we use the asterisk (*):
1. between a data type and identifier in pointer declaration.
eg: int* myNum;
2. As the unary dereference Operator.
eg: *myNum = 400;
3. used as the binary multiplication operator.
eg: int myNum = hisnum * hernum

# Dynamic Memory:
->is allocated at runtime instead of being set at compile time.
->useful bcuz often we don't know how many of certain variables we will need.

## c++ syntax for dynamic memory:
->the NEW keyword allows us to reserve memory on the free store, more commonly known as the HEAP.
->the DELETE keyword is for returning dynmically allocated memory when we're done using it.

Const Correctness:
---
>1. Const correctness refers to how to use the const keyword correctly in different circumstances.
{involving pointers}
---
>2. Four Scenarios:
- Non-Constant Pointer to non-constant data
- Constant pointer to non-constant data
- Non-Constant Pointer to constant data
- Constant Pointer to constant data
---