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
- Host: GitHub
- URL: https://github.com/yashlad27/cpp_revision_repo
- Owner: yashlad27
- License: gpl-3.0
- Created: 2022-07-22T14:33:23.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2022-10-03T07:52:28.000Z (almost 4 years ago)
- Last Synced: 2025-04-15T01:51:55.858Z (over 1 year ago)
- Topics: cpp, dsa, dsa-practice
- Language: C++
- Homepage:
- Size: 628 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
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
---