0

I've declared this class 'Robot' :

 #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]);

 };

 #endif

Robot.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;
}

but when i try to compile i get this error :

6 IntelliSense: member "Robot::N_ROBOT_JOINTS" (declared at line 9 of "e:\documents\visual studio 2012\projects\robotics kinematics\robotics kinematics\Robot.h") is inaccessible e:\Documents\Visual Studio 2012\Projects\Robotics Kinematics\Robotics Kinematics\Robot.cpp 10 43 Robotics Kinematics

2 Answers 2

2

float* forwardKinematics(int theta[Robot::N_ROBOT_JOINTS]) declares a free function, not a member, and so it doesn't have access to Robot's privates.

You probably meant

float* Robot::forwardKinematics(int theta[Robot::N_ROBOT_JOINTS])
//       |
//  notice qualification

This tells the compiler you're implementing the member, and thus allowed to access the class' privates.

0
1

If forwardKinematics is a member of Robot you need to put in the .cpp file

float * Robot::forwardKinematics( int theta[Robot::N_ROBOT_JOINTS] )
{
      // implementation
}

Not the answer you're looking for? Browse other questions tagged or ask your own question.