Help Setting Spark Max Follower

I am having issues setting a Spark Max to follow another Spark Max.

CANSparkMax.h is included in the .h file

'class std::shared_ptr<rev::CANSparkMax>' has no member named 'Follow'

Excerpt from code:

  void Drive::Periodic() {
        Put code here to be run every loop

    // put elevator positions on smartdash   

You are using a pointer, so you have to use the arrow operator to dereference the pointer and call the function, and the pointer dereference operator to dereference the argument.


You can also manually dereference and call the function, which does exactly the same thing, but as one of my professors said, makes you look “like a novice”. You need parentheses because of operator precedence.


The reason you get that error message is you are trying to call Follow on a shared_pointer, and the shared_pointer doesn’t have a Follow method.

I found a stack overflow question that may help you understand pointers in C++ better. It goes into quite a bit of detail that’s not really necessary here, but is good to know.

Good luck.

1 Like

Thank you this helped get me going, I am by no means a Cpp pro. Working on it :slight_smile:

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.