We know C++ supports functions that can carry default values as
follows:
someFunction(in t a, int b, int c =20);
So calling someFunction(x, y) is perfectly legal!
However, if I need to information by reference, can initiate the
referenced variable to a default value?
Eg:
int main()
{
int a = 20;
int b, c;
int &r = a;
someFunction(b, c); // <-------------------- POSSIBLE??
someFunction(b, c,r);//<-------------------- This is allowed
}
someFunction(in t x, int y, int& z = 30); //<-- WELL??
{
}
follows:
someFunction(in t a, int b, int c =20);
So calling someFunction(x, y) is perfectly legal!
However, if I need to information by reference, can initiate the
referenced variable to a default value?
Eg:
int main()
{
int a = 20;
int b, c;
int &r = a;
someFunction(b, c); // <-------------------- POSSIBLE??
someFunction(b, c,r);//<-------------------- This is allowed
}
someFunction(in t x, int y, int& z = 30); //<-- WELL??
{
}
Comment