我宣布这节课为“机器人”:
#ifndef ROBOT_H
#define ROBOT_H
class Robot {
private:
static const int N_ROBOT_JOINTS = 5;
static const int JOINT_PARAM_D1 = 275;
static const int JOINT_PARAM_A2 = 200;
static const int JOINT_PARAM_A3 = 130;
static const int JOINT_PARAM_D5 = 130;
public:
Robot();
float* forwardKinematics(int theta[N_ROBOT_JOINTS]);
};
#endifRobot.cpp
#include "stdafx.h"
#include "Robot.h"
//#define _USE_MATH_DEFINES
//#include <math.h>
Robot::Robot(void)
{
}
float* forwardKinematics(int theta[Robot::N_ROBOT_JOINTS])
{
float* array_fwdKin = new float[Robot::N_ROBOT_JOINTS];
float p_x, p_y, p_z, pitch, roll;
for (int i = 0; i < Robot::N_ROBOT_JOINTS; i++)
{
}
return array_fwdKin;
}但是,当我试图编译时,我会得到以下错误:
6 IntelliSense:成员"Robot::N_ROBOT_JOINTS“(声明在"e:\documents\visual studio 2012\projects\robotics运动学\Robot.h”)第9行)无法访问e:\Documents\Visual 2012\Projects\Robotics运动学\ Robotics Kinematics\Robot.cpp 10 43机器人运动学
发布于 2012-10-23 11:07:58
float* forwardKinematics(int theta[Robot::N_ROBOT_JOINTS])声明了一个免费的函数,而不是成员,因此它无法访问Robot的私处。
你可能是说
float* Robot::forwardKinematics(int theta[Robot::N_ROBOT_JOINTS])
// |
// notice qualification这将告诉编译器您正在实现该成员,从而允许访问该类‘privates’。
发布于 2012-10-23 11:09:01
如果forwardKinematics是Robot的成员,则需要放入.cpp文件
float * Robot::forwardKinematics( int theta[Robot::N_ROBOT_JOINTS] )
{
// implementation
}https://stackoverflow.com/questions/13029092
复制相似问题