Show Menu
Cheatography

OOP244 Cheat Sheet (DRAFT) by

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

Encaps­ulation

Bundling data and methods into a single unit (class)

Constr­uctors and Destru­ctors

The special member function that any object invokes at creati­on-time is called its class' constr­uctor. We use the default constr­uctor to execute any prelim­inary logic and set the object to an ­emp­ty ­state.
The special member function that every object invokes before going out of scope is called its class' destru­ctor. We code all of the terminal logic in this special member­ fu­nction.

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 operat­ors­ be­low).

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 minimi­zes­ cl­ass­ bloat.
 

Function overlo­ading

C++ supports function overlo­ading, where multiple functions with the same name but different parameter lists are defined, and the compiler selects the approp­riate one based on the argument types in a func­tio­n call.

Con- Des- in array

output

Friendship Functions EG

 

Dynamic Memory

'new' and 'delete' operators: Dynami­cally allocate and deallocate memory.
The memory that an applic­ation obtains from the operating system during execution is called­ dy­nam­ic ­memory.
 
Dynamic memory is distinct from the static memory. While the operating system allocates static memory for an applic­ation at load time, the system reserves dynamic memory, allocates it and deallo­cat­es ­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 ri­ght­ op­erand.
 

Dynamic Memory

Constr­uctors and Destru­ctors EG

This() keyword

The this keyword in C++ returns the address of the current object, repres­enting the memory region containing all instance variables. *this refers to the current object itself, encomp­assing its complete set of instance variables, and is used within a member function to access these variables through implic­it ­par­ame­ters.

Helper Fucntions

In object­-or­iented progra­mming, helper functions provide external support to a class by accepting explicit parame­ters. These functions access class objects solely through their parame­ters, often including at least one parameter of the class type. Well-e­nca­psu­lated classes may utilize helper functions for additi­ona­l l­ogic.