Please enable JavaScript.
Coggle requires JavaScript to display documents.
C/C++ 2 (Classes (Friend - Eg. +(class1 a) -> friend ... +(class1 a,…
C/C++ 2
Classes
Friend - Eg. +(class1 a) -> friend ... +(class1 a, class1 b). Basically makes it so the type can change and the operation still work
Operator Overloading Inheritance - Eg. class1 class1::operator+() {etc...}. Basically defines what happens when class1 + class1.
Destructor - Eg. class1::~class1(). Takes no arguments and returns nothing. Basically is used when an instance of that class is removed
-
All functions must be defined with their method signature before being created. Eg. public function1(int a)
-
-
-
Templates - Eg. template <typename T>. T is specified when the function is called, so can be used to store various types
Pointers and memory
-
-
-
-
Unique_ptr - Does not share the pointer, cannot be copied or passed. Can be transferred to another unique_ptr
-
Void Pointer - No data type. Store the address of anything. Gets typecasted when referenced to the data
Function Pointer - Eg. void (*foo)(int) - Defines a pointer to a function that takes int and returns void
C++
-
Structures - Can now have reference variables and member functions. Eg. void swap(int a, int b);
-
Reference Variables - int x; int& r = x; r refers to the same memory location. Treated like a normal int
Class Inheritance
Single, Multiple, Multilevel, Hybrid
-
Inheritance by visibility - Nothing private is inherited. If public inheritance: Everythings stays same. If protected, everything goes to protected. If private, everything goes to private
Constructors - If base class has constructor with args, derived must have one too
Memory Problems
Tree t1, t2; seting t1 = t2 corrupts memory of t1. Solution is to overload = operator
RValue References - Putting g(x+2) into a function g that takes a memory address. Solution: g(int&& n) instead
-
Exceptions
Try Catch - Same as java, any exception is "exception&"