Open YouseYeung opened 11 years ago
Use case for your reference.
FundamentalValue fv(100);
int out_value = 0;
fv.GetAsInteger(&out_value); // should return true, and out_value will be 100.
bool flag = false;
fv.GetAsBoolean(&flag); // should return false, and flag doesn't change.
3Q!!!
FundamentalValue fv(100); double out_value = 0; fv.GetAsInteger(&out_value);
// Should it retrun true or false?
Your code can compile? The argument of GetAsInteger
only receive int*
, and you pass a double*
.
FundamentalValue fv(100); double out_value = 0; fv.GetAsDouble(&out_value);
It retrun false,doesn't it?
Yes @acefromsysu .
Thanks for your reply. ^ ^
How to judge the data type of fv ?
@Yueyi Please read the homework_4.pdf
. The answer is easy enough to get.
OK,I got it.
// These methods allow the convenient retrieval of settings. // If the current setting object can be converted into the given type, // the value is returned through the |out_value| parameter and true is // returned; otherwise, false is returned and |out_value| is unchanged. virtual bool GetAsBoolean(bool* out_value) const; virtual bool GetAsInteger(int* out_value) const; virtual bool GetAsDouble(double* out_value) const; virtual bool GetAsString(std::string* out_value) const; 求师兄用中文解释一下,小弟英文水平太渣了 T T