View Single Post
  #6   Spotlight this post!  
Unread 02-02-2015, 12:27
one_each one_each is offline
Registered User
FRC #4057 (KB Bots)
Team Role: Mentor
 
Join Date: Jun 2012
Rookie Year: 2012
Location: Klamath Falls, Or
Posts: 25
one_each is an unknown quantity at this point
Re: Declaring DoubleSolonoid

Here is a bit of explenation.

Could not convert '(operator new(104u), (<statement>, ((DoubleSolenoid*) <anonymous>)))' from' 'DoubleSolenoid*' to 'DoubleSolenoid'

The bolded parts are the important notes. Note the asterisk (or 'star') in the from and also note that it is missing in the to.

The new operator creates a new version of the class (DoubleSolenoid here) and returns a pointer to it. The asterisk (or 'star') indicates changes the type of grabSolenoid to a "pointer to DoubleSolenoid", thus making the types on both sides the same.

Pointers are one of the more confusing aspects of C/C++, however they are used everywhere. Remember, the pointer doesn't hold the data, it just points to where it is at. For classes, use the -> operator to access methods and fields from the pointer.
Reply With Quote