commenting parameter in function definition

1
2
3
4
5
6
7
8
9
10
11
12
13
14
class Test
{
	public:
		void Print(int /* arguement*/)   // where will it receive, why compiler doesn't throw error
		{
			std::cout<<"Still Works\n";
		}
}; //~ Endls Test Class

void main()
{
	Test obj1;
	obj1.Print(10);     // 10 is passed
}//~ main Ends 


Where the parameter will be received in the Test::Print function?
The parameter will still be received by the Print function - however, inside the Print function you will not be able to use it because you have not given it a name.

EDIT:
This concept of not giving function parameter names is useful sometimes.
There are time when you may have to create a function that takes parameters but you are
not going to make use the parameters (I know it sounds strange) - in that case you don't
give the parameter a name - because if you give a parameter a name but do not use it - the compiler
will give a warning that - "variable_name/parameter_name" is not used.

If the variable does not have a name, then the compiler won't give the warning.
Last edited on
Thanks Guestgulkan!!!
Topic archived. No new replies allowed.