Cheatography
https://cheatography.com
Object oriented programming
This is a draft cheat sheet. It is a work in progress and is not finished yet.
Name and student ID
Name: Krishang jignesh patel |
Student ID: 147964225 |
Encapsulation
Bundling data and methods into a single unit (class) |
Constructors and Destructors
The special member function that any object invokes at creation-time is called its class' constructor. We use the default constructor to execute any preliminary logic and set the object to an empty state. |
The special member function that every object invokes before going out of scope is called its class' destructor. We code all of the terminal logic in this special member function. |
Unary operators
A unary operation consists of one operator and one operand. The left operand of a unary member operator is the current object. The operator does not take any explicit parameters (with one exception - see post-fix operators below). |
Friendship Functions
Friendship grants helper functions access to the private members of a class. By granting friendship status, a class lets a helper function access to any of its private members: data members or member functions. Friendship minimizes class bloat. |
|
|
Function overloading
C++ supports function overloading, where multiple functions with the same name but different parameter lists are defined, and the compiler selects the appropriate one based on the argument types in a function call. |
|
|
Dynamic Memory
'new' and 'delete' operators: Dynamically allocate and deallocate memory. |
The memory that an application obtains from the operating system during execution is called dynamic memory. |
|
Dynamic memory is distinct from the static memory. While the operating system allocates static memory for an application at load time, the system reserves dynamic memory, allocates it and deallocates it at run-time. |
Current object (this()) EG
Binary Operators
A binary operation consists of one operator and two operands. In a binary member operator, the left operand is the current object and the member function takes one explicit parameter: the right operand. |
|
|
Constructors and Destructors EG
This() keyword
The this keyword in C++ returns the address of the current object, representing the memory region containing all instance variables. *this refers to the current object itself, encompassing its complete set of instance variables, and is used within a member function to access these variables through implicit parameters. |
Helper Fucntions
In object-oriented programming, helper functions provide external support to a class by accepting explicit parameters. These functions access class objects solely through their parameters, often including at least one parameter of the class type. Well-encapsulated classes may utilize helper functions for additional logic. |
|