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: 24th November 2016.
◕ What is Variable Declaration & Variable Definition in C++ ?
Let a simple program:
using namespace std;
int world = 6;
int sky = 3;
water = world + sky;
cout << "The total is:" << water << endl;
◕ 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
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