returnType varF() {return var;}
=> Getter functions are used to get private data members from a public functionreturnType varF(parameter) {statement}
=> Setters are public functions used to set/declare values of private data members in the class class varC {
private: statement;
public: statement;
protected: statement;
};
varC varO
=> Create a instance of the Class known as Objects, Scope is localvarC varO[]
=> Create a array of objectsvarO.var
=> Access the variables in the classvarO.varF()
=> Call a function inside varC of publicreturnType varC::varF() {}
=> Using scope operator to define a varC member function outside varC classvarC () {statement;}
=> Creating a Default Constructor, Without any parametervarC(returnType var): var(value){}
=> For initializing members of the class and it is valid when using constructorsvarC (parameter) {statement;}
=> Creating a Parameterized Constructor, Give default values to use it as a default constructor varC (varC &varO) {
// statement
}
// Call the constructor
varC varO2(varO1)
varC varO2 = varO1
~varC () {statement;}
=> Creating a De-constructor, Gets called when a object gets destroyed, After exiting the main function static dataType var;
dataType varC::var = value;
varC::varF();
static varC varO
=> Scope of static object is through out the life time of programstatic returnType varF() {statement;}
returnType varF() const {return value;}
=> Inside this you can't modify a data variable, can be called on any type of objectconst varC varO
=> An object declared as const cannot be modified class varC2 : accessModifier varC1 {
// statement
}
class varC2 : accessModifier varC1, accessModifier varC2 {
// statement
}
returnType operator operatorSymbol() {}
=> Operator overloading Function for unary operatorreturnType operator operatorSymbol(dataType &var) {}
=> Operator overloading Function for binary operatorfriend ostream &operator<<(ostream &output, varC &varO) { output << varO.var1 << varO.var2; return output; }
=> Output overloadingcout << varO;
=> Call itfriend istream &operator>>( istream &input, varC &varO ) { input >> varO.var1 >> varO.var2; return input; }
=> Input Overloadingcin >> varO
=> Call itreturnType varF() {statement;}
=> Function OverloadingreturnType varF(dataType &var) {statement;}
friend class varC
=> Declare a class as friend, Can access non-public members using an objectfriend returnType varC2::varF(varC1&)
=> Declare a function of another class as friend which can access even private members though Object friend returnType varF(varC&)
returnType varF(varC& var) {
// statement
}
varC2 *ptr = (*ptr).varF()
ptr -> varF()
virtual returnType varF(parameter) {
// statement
}&varO
class varC2 : virtual accessModifier varC1 {
// statement
}
class varC2 : accessModifier virtual varC1 {
// statement
}
virtual returnType varF() = 0;
=> Pure Virtual Function, Object can't be created from an abstract class, Must override in derived class to make it work