STRUGGLING WITH C++ CONSTRUCTOR ARGUMENTS
So, I've just came from TS/JS/Py and trying to understand C++ concepts. But I'm struggling with using the parameter of constructor of the class FOR declaring default value for an argument. Here is the code I'm trying to run:
double Phythagorean_Hypotenuse (int& a, int& b ) { return sqrt((a * a) + (b * b)); }; class Triangle { public: int a; int b; double c; Triangle(int a_param, int b_param, double c_param = Phythagorean_Hypotenuse(a_param, b_param)) { a = a_param; b = b_param; c = c_param; } }; and inside of the main function
Triangle mytri_1(10, 20); std::cout << mytri_1.a << std:endl; But when I try to run this code, IDE is throwing me some errors like
[Error] 'a_param' was not declared in this scope or
[Error] call to 'Triangle::Triangle(int, int, double)' uses the default argument for parameter 3, which is not yet defined So, please, can someone who can fix this answer the question?
Thanks.