9 AnswersNew Answer
Declaration of a variable is for informing to the compiler the following information: name of the variable, type of value it holds and the initial value if any it takes. i.e., declaration gives details about the properties of a variable. Whereas, Definition of a variable says where the variable gets stored. no, you can't call a parameter as variable. Variables are kinda label for the memory that stores the actual data. Pointers stored the address of the variables. References are alias for the variables.
For a variable X: // declararion int x; // definition x = 20; // declaration & definition int x = 20; All variables must be declared before defining them and whenever you define a variable, you're simply assigning a value to them. Also a parameter is a variable, whenever you call a function with a parameter, a copy of such parameters are implicitly created except if the parameters are passed by reference. void foo(int x) // a copy of x is created void foo(int &x) // referenced reference is a pointer to a variable. So a reference POINT AT a variable
...the title and description aren't matching. do you wanna ask about all four or any two?
Coding Kitty Does function hold space in memory too?
they do. even if you don't call them in the main function. but you shouldn't be concerned about that for now.
codingKitty might have his/her reason for saying that but to me, a parameter is a local variable that also have their separate address in memory. Whenever you call a function ¶meter = copy of the argument Except if the parameter's declaration was preceded by the reference operator
Coding Kitty I am sorry for this All four..
Mirielle Ok, variable declaration and defination - ✅ But are you calling parameter a variable?? Coding Kitty said, parameters and variables aren't same...:/ I don't get it..
Mirielle https://code.sololearn.com/cq1S7wD2B9vx/?ref=app Here parameter has an adress too.. 🤔 Whatever, I ran the program 10-12 times and it's changes memory location.. Can you please search for where did I go wrong??