Posts

Showing posts from August, 2020

Electricity Bill Generator Project in C++

C++ project on Electricity Bill Generator: ☝This project does not include file handling so it does not store the data gathered as input permanently. The data stored gets destroyed as the program ends. #include<iostream> using namespace std; class EBill      {        private:         string name;         protected:         unsigned int acc;        public:         void input()              {               cout<<"\nEnter ur name::";    cin>>name;               cout<<"\nEnter ur account no::"; cin>>acc;              }         void display()              {              cout<<"\nUr n...

Virtual function in c++

Virtual Function: Virtual means existing in effect but not in reality. A type of function that appears to exist in some part of the program but does not exist really is called a virtual function. Virtual functions are used to implement polymorphism. They enable the user to execute completely different functions by the same function call. A virtual function is defined in the parent class and is overridden in child classes. It is defined by the keyword virtual. If you want to call a virtual function in C++ and execute the redefined version of the member function, you can achieve this task using a pointer or a reference ( -> ) by referring a derived class object to the base class. A base class pointer has the capability to point to the objects of the base class and the derived class. But it's converse is not true. An example of using virtual function with reference: #include<iostream> using namespace std; class Animal {     public:         virtual ...