Startertutorials Blog
Tutorials and articles related to programming, computer science, technology and others.
Subscribe to Startertutorials.com's YouTube channel for different tutorial and lecture videos.
Home ยป Page 30

Cpp program to create a function template to swap two numbers

Suryateja Pericherla Categories: Templates. No Comments on Cpp program to create a function template to swap two numbers

In this article we will learn to implement a Cpp program to create a function template to swap two numbers. A C++ program is provided below to create a function template for swapping.   Program is as follows: #include <iostream> using namespace std; template<class T> void swapme(T &x, T &y) { T temp = x; […]

Read the rest of this entry »

CPP program to create a function template for power of a number

Suryateja Pericherla Categories: Templates. No Comments on CPP program to create a function template for power of a number

In this article we will learn to implement a CPP program to create a function template for power of a number. A C++ program is provided below to create a function template for calculating power of a number.   Program is as follows: #include <iostream> #include <cmath> using namespace std; template<class T> void power(T x, […]

Read the rest of this entry »

CPP program to illustrate member function template

Suryateja Pericherla Categories: Templates. No Comments on CPP program to illustrate member function template

In this article we will learn to implement a CPP program to illustrate member function template. A C++ program is provided below to illustrate member function template.   Program is as follows: #include <iostream> using namespace std; class Adder { public: template<class T1, class T2> void add(T1 x, T2 y) { cout<<"Sum is: "<<(x+y)<<endl; } […]

Read the rest of this entry »

CPP program to illustrate class template with multiple parameters

Suryateja Pericherla Categories: Templates. No Comments on CPP program to illustrate class template with multiple parameters

In this article we will learn to implement a CPP program to illustrate class template with multiple parameters. A C++ program is provided below to demonstrate a template class with multiple parameters.   Program is as follows: #include <iostream> using namespace std; template<class T1, class T2> class Adder { private: T1 x; T2 y; public: […]

Read the rest of this entry »

CPP program to illustrate template class

Suryateja Pericherla Categories: Templates. No Comments on CPP program to illustrate template class

In this article we will learnt to implement a CPP program to illustrate template class. A C++ program is provided below to illustrate class template.   Program is as follows: #include <iostream> using namespace std; template<class T> class Swapper { private: T x; T y; public: Swapper(T x, T y) { this->x = x; this->y […]

Read the rest of this entry »

Pure Virtual Function Program in C++

Suryateja Pericherla Categories: Inheritance. No Comments on Pure Virtual Function Program in C++

In this article we will learn how to implement a pure virtual function program in C++. A C++ program is provided to illustrate the concept of pure virtual function and calculate the area of different shapes by using abstract class. Program is as follows: #include <iostream> using namespace std; class Shape { public: virtual void […]

Read the rest of this entry »

CPP program to demonstrate runtime polymorphism

Suryateja Pericherla Categories: Polymorphism. No Comments on CPP program to demonstrate runtime polymorphism

In this article we will look at how to implement a CPP program to demonstrate runtime polymorphism. A C++ program is provided below to illustrate runtime polymorphism. Program is as follows: #include <iostream> using namespace std; class Animal { public: virtual void sound() = 0; virtual void move() = 0; }; class Dog : public […]

Read the rest of this entry »

CPP program to show how constructors are invoked in derived class

Suryateja Pericherla Categories: Inheritance. No Comments on CPP program to show how constructors are invoked in derived class

In this article we will try to implement a CPP program to show how constructors are invoked in derived class. A C++ program is given below to demostrate how constructors are invoked in derived class.   Program is as follows: #include <iostream> using namespace std; class A { protected: int x; public: A(int p) { […]

Read the rest of this entry »

CPP program to illustrate the order of execution of constructors and destructors in inheritance

Suryateja Pericherla Categories: Inheritance. No Comments on CPP program to illustrate the order of execution of constructors and destructors in inheritance

In this article we will learn to implement a CPP program to illustrate the order of execution of constructors and destructors in inheritance. A C++ program is provided below to demonstrate in which order constructors and destructors are executed in inheritance.   Program is as follows: #include <iostream> using namespace std; class A { public: […]

Read the rest of this entry »

CPP program to implement virtual base class

Suryateja Pericherla Categories: Inheritance. No Comments on CPP program to implement virtual base class

In this article we will learn to implement a CPP program to implement virtual base class. A C++ program is provided below to illustrate virtual base class.   Program is as follows: #include <iostream> using namespace std; class A { protected: int x; }; class B : virtual public A { private: int y; public: […]

Read the rest of this entry »
Facebook
Twitter
Pinterest
Youtube
Instagram
Blogarama - Blog Directory