skr*_*obo 0 c++ variables class definition
假设我有一个Sensor如下所示的课程:
class Sensor
{
public:
Sensor();
array <float, 3> marker_pos(float, float, float);
private:
float range;
float phi;
array <float, 3> temp;
int flag = 0;
};
Run Code Online (Sandbox Code Playgroud)
变量range和phi是属性或传感器对象的变量.但变数temp和flag只是正常的变量,这些变量的函数内使用marker_pose.
1.在课程中定义/声明temp和flag内部是不好的做法?
2.如果我在函数内定义/声明它们marker_pose,每次调用该函数时都会定义它.这是一个好主意吗?
3.在这种情况下,最佳做法是什么?