Home   |   About   |   Terms   |   Contact    
A platform for writers

What is Variable Declaration & Variable Definition in C++


☯ All C++ Articles     ☯ All Articles

Popular Google Pages:

◕ Send your story to RiyaButu.com and get ₹ 500/- Details..

◕ Bengali Story writing competition. Details..

This article is regarding Variable Declaration & Variable Definition in C++.
Last updated on: .

What is Variable Declaration & Variable Definition in C++ ?

Let a simple program:
#include <iostream>
using namespace std;
int world = 6;
int sky = 3;
int water;
int main()
water = world + sky;
cout << "The total is:" << water << endl;
return 0;

◕ Variable Declaration:
A variable declaration is a statement that declare the name & type of a variable.
In the above program
int world = 6; is a Variable Declaration.

◕ Variable Definition:
In order to store data in a variable, we need to have an associated piece of the computer’s memory with that variable name to store the value of that variable. This is called Variable Definition.

But when we declare a variable it automatically contains some computer’s memory.

For an example:
In the above program the statement
int world;
has both a Variable Declaration and a Variable Definition.

If this is the situations then what is the difference between these Variable Declaration and Variable Definition?

The answer is, the difference between these two is that in C++ there are some situations where we have a statement, which is only a Declaration but not a Definition.

Top of the page

Amazon & Flipkart Special Products


Top of the page