Function Overloading

To understand function overloading, we need to understand the concept of polymorphism. Polymorphism means having many or multiple forms. There are two type of polymorphism.1) Static Polymorphism2) Dynamic Polymorphism Function overloading comes under static Polymorphism. Function overloading means functions with same name but different number or type of arguments.Let us understand with the help of example. #include <iostream>using namespace std;class base {public: void display(int num) { cout << “Num: ” << num << endl; } void display(int num1, int num2 = 10) { cout << “Num1: ” << num1 <<…

Composition

Every big thing is made up of small-small things. For example, a house is built from walls, ceiling, and doors. Now in terms of C++, we can say that every complex object is built from small or simple object. This process of creating a complex object from simple and small objects is called composition in C++. In other words, whenever there is “has-a” relationship, then composition comes in to picture. E.g., house has four walls, two doors and one ceiling. Let us try to understand the concept of composition with…

IF AND THEN STATEMENT IN SAS

In this post, I will discuss about the “If and then Statements in SAS”. Here , I have created the dataset where I have mentioned emp_id in numbers as well as single character. See the below SS related to Dataset created.Now, on the above dataset I will apply If and then statement and assign numbers to single character emp_id. See the below code for the same. DATA EMP_NEW_DET;SET EMP_DET;IF EMP_ID=”A” THEN EMP_ID= “1”;ELSE IF EMP_ID=”B” THEN EMP_ID= “2”;RUN; Once you execute the above code, the below output will appear.

SUM USING GROUP BY IN SAS

In this post, I will discuss about “How to perform sum function based on particular column in SAS”. In one of my blog , I have already explained about Sorting in SAS using Employee Data. Once sorting is done based on the Emp_id, I will sum the salary the based on the emp_id. Below is the code for the same. DATA EMP_SUM_DET(drop=SALARY);SET EMP_DET;BY EMP_ID;if First.EMP_ID then TotalSalary=0;TotalSalary+SALARY;if Last.EMP_ID;run;Here, we are using If, first and last function . For each employee, we are setting the intial TotalSalary=0 . Here , another…

SORT DATA IN SAS

In this post, I will discuss How to sort data in SAS. Sorting plays a very important role in SAS. With and without sorting, data changes drastically in SAS. Consider the below data lines in SAS. DATA EMP_DET; INPUT EMP_ID SALARY; DATALINES; 1 10000 2 10500 3 12000 1 13000 2 12300 3 15000 ; run; When the above code executes, the output will be as below.As it is clearly seen, data is neither sorted by salary nor by emp_id. In order to sort the data, “proc sort” syntax is…

Explicit conversion constructor

Consider an example below to understand the concept of explicit constructor #include <iostream>using namespace std;class person {private: unsigned int m_age; char m_gender;public: person (unsigned int age = 40, char gender = ‘M’); bool operator==(const person& other) { cout << “Comparison”<< endl; if ((other.m_age == m_age) && (other.m_gender == m_gender)) { return true; } return false; }};person::person(unsigned int age, char gender){ cout << “C’tor” << endl; m_age = age; m_gender = gender;}int main() { person p(40, ‘M’); person p1 = 40; //Implicit conversion if ( p == 40) { //Implicit conversion…

802.1Q VLAN Trunking

Let us take the below topology to understand the concept of trunking in switches.In the below topology, we have total four PC devices. PC-1 and PC-3 are connected to access port of switch 1 and under VLAN 22 and 23 respectively. Similarly, PC-2 and PC-4 are connected to access port of switch 2 and under VLAN 22 and 23 respectively. Let us say PC-1 wants to send a message to PC-2. Both are under VLAN 22(under same network: 44.44.44.0) but both the PCs are connected to different switches. Below is…

Switch Virtual Interface

Switch virtual interface(SVI) is also VLAN interface or logical interface. To understand the concept, let us take the below topology: There are two PCs connected to switch. PC-1 is connected to Fa0/8 port and PC-2 is connected to Fa0/9. Both the ports of the switch are in different VLAN as you can see above. In addition, both PC are on different IP Network. PC-1 is on 44.44.44.0 Network and PC-2 is on 55.55.55.0 Network.Since both the PCs are on different VLAN (different broadcast domain), they cannot communicate with each other.…

Constructor & Destructor

Constructor :As name suggest, it construct an object. Constructor is used to initialize the data members of a class.Consider a class below: #include <iostream>#include <string> using namespace std;class employeeData { unsigned int m_salary; char* m_name;public: ~ employeeData() { //Destructor if (m_name) { delete []m_name; } } employeeData() { // default constructor cout << “employeeData default C’tor” << endl; m_salary = 0; m_name = NULL; } employeeData(unsigned int salary, char* name) { //Parameterized constructor cout << “employeeData parameterized C’tor” << endl; m_salary = salary; unsigned int len = strlen(name); m_name =…

Static member

When we add a static data member in class, it will have only one copy per class.Let us understand with an example.//Header file#include <iostream>using namespace std;class base {     static unsigned int m_classMember; //static data member    unsigned int m_objectMember; //nonstatic data memberpublic:    base() {         m_objectMember = 0;        ++ m_classMember;         ++ m_objectMember;       cout << “Count: “ << m_classMember  << “ “ << m_objectMember <<           endl;    }}; //Source file:unsigned int…