Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kanishkrawatt/cpp
A collection of resources to learn object-oriented programming and related concepts With cpp
https://github.com/kanishkrawatt/cpp
cpp markdown
Last synced: 19 days ago
JSON representation
A collection of resources to learn object-oriented programming and related concepts With cpp
- Host: GitHub
- URL: https://github.com/kanishkrawatt/cpp
- Owner: Kanishkrawatt
- Created: 2022-07-27T17:52:55.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-02-17T06:02:24.000Z (over 1 year ago)
- Last Synced: 2024-10-11T13:38:56.232Z (about 1 month ago)
- Topics: cpp, markdown
- Language: C++
- Homepage:
- Size: 1.92 MB
- Stars: 9
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
## C++
C++ is a general-purpose programming language created by Bjarne Stroustrup as an extension of the C programming language, or "C with Classes".
The language has expanded significantly over time, and modern C++ now has [object-oriented](/Oops), generic, and functional features in addition to facilities for low-level memory manipulation. It is almost always implemented as a compiled language.
| Content | Other Topics | Units |
| ----------------------------------------------------------------- | ------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
| [Difference between C and C++](#difference-between-c-and-c) | [Object Oriented Programming(oops)](/Oops) | Unit 1 : [Basic](#difference-between-c-and-c) , [Oops](/Oops) |
| [Input and Output in C and C++](#input-and-output-in-c-and-c) | [Data Structure]() | Unit 2 : [Classes](/Oops/Class/) , [Constructor-Destructors](/Oops/Constructor-Destructor/) |
| [Constants in C++](#constants-in-c) | [Basic C++]() | Unit 3 : [Inheritance](/Oops/Inheritance/) , [Polymorphism](/Oops/Polymorphism/) , [Operator Overloading](/Oops/OperatorOverloading/) |
| [Literals](#literals) | [Algorithms](/Algorithms) | Unit 4 : [Parametric polymorphism](/Oops/ParametricPolymorphism/) , [Exception Handling](/Oops/ExceptionHandling/) , [Streams &Files](/Oops/Stream/) |
| [Qualifiers](#qualifiers) | [Competitive Questions](/compe) |
| [Operators](#operators) |
| [Reference variable](#reference-variable) |
| [Functions](#functions) |
| [Default Arguments](#default-arguments) |
| [Inline Function](#inline-function) |
| [Parameter Passing by Value](#parameter-passing-by-value) |
| [Parameter Passing by Reference](#parameter-passing-by-reference) |
| [Parameter Passing by Pointer](#parameter-passing-by-pointer) |
| [Constructor/Distructor](/Oops/Constructor-Distructor/readme.md) |
| [Inheritance](/Oops/Inheritance/readme.md) |
| [Polymorphism](/Oops/Polymorphism/readme.md) |
| [Operator Overloading](/Oops/OperatorOverloading/readme.md) |
| [Virtual Function](/Oops/VirtualFunction/readme.md) |
| [Parametric Polymorphism](/Oops/ParametricPolymorphism/readme.md) |
| [Exception Handling](/Oops/ExceptionHandling/readme.md) |
| [Stream](/Oops/Stream/readme.md) |##### Difference between C and C++
| C | C++ |
| ---------------------------------------------------------------- | ----------------------------------------------------------- |
| C was developed by **Dennis Ritchie** between _1969_ and _1973_. | C++ was developed by **Bjarne stroustrup** in _1979_. |
| C is (mostly) a subset of C++. | C++ is (mostly) a superset of C. |
| Is supports Procedural Programming. | It Support both Procedural and object Oriented Programming. |
| It Does not support Information hiding and encapsulation. | It does support Information hiding and encapsulation. |
| It is function-driven language. | It is Object-drivedn language. |
| Standard I/O header is . | Standard I/O header is . |
| It provides **Malloc()** and **Calloc()** for memory allocation | It provides **New** operator for memory allocation |
| It provides **free()** for Memory de-allocation. | It provides **Delete** |##### Input and Output in C and C++
```cpp
// Output(print) in C
int a = 10;
printf("%d",a);// Output(print) in C++
int a = 10;
cout<>a;
```##### Constants in C++
**const** modifier is used to create constants.
Variables whose value cannot be changed once they are initalized.```cpp
Syntax:
const type variable_name = value;```
```cpp
example:
int main()
{
const int i = 10;
i = 20 // Error ! Cann't change value of i
// (since it is a constant)
}```
##### Literals
Literals are data used for representing fixed point values that we can directly use in the code.
```cpp
example:
10, 20, 3.14, 'a', etc.```
##### There are 4 types of literals
- Integer Literal
```
- Decimal Literal
examples:
0, -1, 100, 20, etc.
- Octal Literal (starts with 0)
examples:
045, 065, 043 , etc.
- Hexadecimal Literal (starts with 0x)
examples:
0x8f, 0x2a, 0x721, etc.
- Floating Point Literal
It has a integer part, a decimal point,
a fractional part , and an exponent part.
example:
3.14134, 4e-11 , 1E-5,```
- Boolean Literal
```cpp
- true
- false
```
- Character Literal
```cpp
- 'a'
- 'b'
- 'c'
```
- String Literal
```cpp
- "Hello World"
- "C++"
```##### Qualifiers
Qualifiers are used to modify the meaning of the type.
- **const** : It is used to create constants.
- **volatile** : It is used to modify the variable.
- **restrict** : It is used to restrict the pointer.##### Operators
Operators are used to perform operations on variables and values.
- **Arithmetic Operators**
```cpp
- Addition (+)
- Subtraction (-)
- Multiplication (*)
- Division (/)
- Modulus (%)
- Increment (++)
- Decrement (--)
```
- **Relational Operators**
```cpp
- Equal to (==)
- Not equal to (!=)
- Greater than (>)
- Less than (<)
- Greater than or equal to (>=)
- Less than or equal to (<=)
```
- **Logical Operators**
```cpp
- Logical AND (&&)
- Logical OR (||)
- Logical NOT (!)
```
- **Bitwise Operators**
```cpp
- Bitwise AND (&)
- Bitwise OR (|)
- Bitwise XOR (^)
- Bitwise NOT (~)
- Bitwise Left Shift (<<)
- Bitwise Right Shift (>>)
```
- **Assignment Operators**
```cpp
- Assignment (=)
- Addition Assignment (+=)
- Subtraction Assignment (-=)
- Multiplication Assignment (*=)
- Division Assignment (/=)
- Modulus Assignment (%=)
- Left Shift Assignment (<<=)
- Right Shift Assignment (>>=)
- Bitwise AND Assignment (&=)
- Bitwise OR Assignment (|=)
- Bitwise XOR Assignment (^=)
```
- **Miscellaneous Operators**
```cpp
- Sizeof
- Comma (,)
- Ternary (?)
- Pointer to member (.*)
- Member of pointer (->*)
```
- **Conditional Operator**
```cpp
Syntax:
condition ? expression1 : expression2;
```
```cpp
example:
int a = 10;
int b = 20;
int c = a > b ? a : b;
cout<*pointer_to_member
```
```cpp
example:
class A
{
int a;
public:
void set(int x)
{
a = x;
}
int get()
{
return a;
}
};
int main()
{
A obj;
obj.set(10);
int A::*p = &A::a;
cout<*p<>
6. <, <=, >, >=
7. ==, !=
8. &
9. ^
10. |
11. &&
12. ||
13. ?:
14. =, +=, -=, *=, /=, %=, <<=, >>=, &=, ^=, |=
```
```cpp
Associativity:
1. Left to Right
2. Right to Left
```#### Reference variable
Reference variable is an alias/another name of another variable.
```cpp
Syntax:
type &reference_variable = variable;
``````cpp
example:
int a = 10;
int &b = a;
```#### Functions
A function is a group of statements that together perform a task.
```cpp
Syntax:
return_type function_name (parameter list)
{
body of the function
}
``````cpp
example:
int add(int a, int b)
{
return a + b;
}
```##### Default Arguments
Default arguments are used to provide default
values to the parameters of a function.```cpp
Syntax:
return_type function_name (parameter list = default_value)
{
body of the function
}
``````cpp
example:
int add(int a, int b = 10)
{
return a + b;
}
int main(){
cout<