Skip to main content

Posts

C++ Cheat Sheet

 Friend Function: Non-member function that can access members (private + protected) of class Friend keyword is used during declaration only Defined globally outside of class scope (it does not belong to any class) Used in operator overloading Not in java Friend Class: Can access private + protected members of other class without inheritance Friendship is NOT mutual Violates data hiding hence avoid Static:  When a variable in a class is declared static, space for it is allocated for the lifetime of the program. No matter how many objects of that class have been created, there is only one copy of the static member. So same static member can be accessed by all the objects of that class. A static member function can be called even if no objects of the class exist and the static function are accessed using only the class name (A) and the scope resolution operator :: cout<<A::a(); Abstract class : template for another class A class is called an abstract class whose objects c...
Recent posts

Data Representation

 Digital Number System In digital representation, various number systems are used. The most common ones are : Binary : base 2 (0, 1) Octal : base 8 (0, 1, 2, 3, 4, 5, 6, 7) Decimal : base 10 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9) Hexadecimal : base 16 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F) Number Conversions : From Decimal to any system (base) (Decimal) 10 = (Any) base

WAP to check whether the given character is uppercase, lowercase, digit or special character

 

Basic OOP concepts

Data Abstraction :  representing essential features without including background details. Example : driving a car (wiring, motor working is hidden from us), switch board (hidden wiring)

Cheat sheet

 A ( 65 ) - Z ( 90 ) a ( 97 ) - z ( 122 ) 0 ( 48 ) - 9 ( 57 ) enter - 13 space - 32 @ - 64 Who calls main()?   OS.  Execution starts at main. <<  : output / put to / stream insertion operator >>  : input / get from / stream extraction operator calculation R to L printing L to R

Selection statement

  If statement  If tests a particular condition, if the condition evaluates to true then set of statements under the body of 'if' statement will be executed otherwise it will be ignored by the compiler. Syntax : if(<condition>) {      statements; } <> : programmer defined If else statement If we use 'else' statement with 'if' statement then if the condition of 'if' statement evaluates to false, in that case body of else statement will be executed, otherwise it will be ignored. Syntax :  if(<condition>) {      statements; } else {     statements; } If-else-if ladder If we use 'else if' statement with 'if' statement then if any condition evaluates to true, in that case its associated statement will be executed and all other 'else if' and 'else' statement will be ignored by the compiler. Syntax :  if(<condition>) {      statements; } else if(<condition>) {    statements; } els...

Operators

  The operations are represented by operators and the object of the operation are referred to as operands. 5 types of operators: 1. Arithmetic Operator  Addition : 2 + 4 = 6 Subtraction : 2 - 4 = -2 Multiplication : 2 * 4 = 8 Division : 2 / 4 = 0 Modulus (remainder operator, used only with integer values) : 7 % 2 = 1 2. Increment (++) / Decrement (--) Operator Increment Operator increases its operand value by 1 while decrement operator decreases its operand value by 1.  They both have two types : Prefix : First it will increase (or decrease) the operand value by one and then participate in the operation. Postfix : First it will participate in the operation and then increase (or decrease) the operand value by 1. 3. Relational Operator They determine the relation among different operands. But they do not work with strings. 6 types of relational operator are: > greater than < less than >= greater than or equals to <= less than or equals to == equal to != not equ...