从另一个类的静态成员调用一个类的非静态成员

我有两节课。

编码器

#include "stationControl.h"

    public:
         static void getLocation();
         static stationControl *station1;
         static stationControl *station2;
         static stationControl *station3;
    private:
         static stationControl *stations[3];

编码器

#include "encoder.h"

stationControl *encoder::station1;
stationControl *encoder::station2;
stationControl *encoder::station3;

stationControl *encoder::stations[] = {encoder::station1,encoder::station2,encoder::station3};

void encoder::getLocation()
{
  *stations[1]->*stationControl::senarioControl(); // Here is the problematic line
}

stationControl.h

   public:      
      void (stationControl::*senarioControl)();
      void controlOut();

stationControl.cpp

#include "stationControl.h"

stationControl::stationControl()
{   
    senarioControl= &stationControl::controlOut;
}

void stationControl::controlOut()
{
     // some staffs...
}

  • 我需要在encoder.h中的静态stationControl对象
  • 我需要为每个stationControl对象使用非静态controlOut函数(每个函数都针对其对象)
  • 我需要为controlOut函数创建一个指针作为senarioControl
  • 我需要从编码器:: getLocation调用senarioControl指针

就像上面encoder.cpp中的代码(用“ //这是有问题的行”签名)一样,我收到类似的错误;

invalid use of member 'stationControl::senarioControl' in static member function