Go to Post It doesn't matter what goes wrong as long as you have fun. We all thought this was one of our best trips, even though we were second to last in our divison. - afowl [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 02-02-2015, 16:03
RobHammann RobHammann is offline
Registered User
FRC #5143
 
Join Date: Jan 2015
Location: Grand Rapids MN
Posts: 8
RobHammann is an unknown quantity at this point
Re: Declaring DoubleSolonoid

Thanks, they do declare now, however...

Quote:
Originally Posted by one_each View Post
For classes, use the -> operator to access methods and fields from the pointer.

I really don't understand these pointers, when I try to set the solenoids using something like

grabSolenoid.set(DoubleSolenoid::kForward);

it says "request for member 'set' in '(((Robot*)this))->Robot::grabSolenoid', which is of pointer type 'DoubleSolenoid' (maybe you meant to use '->' ?)"

where do I put the ->?
Reply With Quote
  #2   Spotlight this post!  
Unread 02-02-2015, 16:14
Steve Warner Steve Warner is offline
Controls / Programming
FRC #0234 (Cyber Blue)
Team Role: Mentor
 
Join Date: Feb 2006
Rookie Year: 2006
Location: Indiana
Posts: 41
Steve Warner is an unknown quantity at this point
Re: Declaring DoubleSolonoid

Try grabSolenoid->Set(DoubleSolenoid::kForward);
Reply With Quote
  #3   Spotlight this post!  
Unread 02-02-2015, 16:20
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,112
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Declaring DoubleSolonoid

Quote:
Originally Posted by RobHammann View Post
...using something like

grabSolenoid.set(DoubleSolenoid::kForward);

it says "request for member 'set' in '(((Robot*)this))->Robot::grabSolenoid', which is of pointer type 'DoubleSolenoid' (maybe you meant to use '->' ?)"

where do I put the ->?
You have declared grabSolenoid as a pointer to a double solenoid object. The member functions like Set() only work on an actual object. You need to dereference the pointer before you can call the function. The '->' is a small bit of syntax convenience that lets you dereference the pointer and do the equivalent of a '.' at the same time.

Just replace the '.' with '->' between the variable name and the function name.
Reply With Quote
  #4   Spotlight this post!  
Unread 02-02-2015, 17:08
GeeTwo's Avatar
GeeTwo GeeTwo is offline
Technical Director
AKA: Gus Michel II
FRC #3946 (Tiger Robotics)
Team Role: Mentor
 
Join Date: Jan 2014
Rookie Year: 2013
Location: Slidell, LA
Posts: 3,574
GeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond repute
Re: Declaring DoubleSolonoid

Quote:
Originally Posted by Alan Anderson View Post
Just replace the '.' with '->' between the variable name and the function name.
Yes. obj_ptr->elt is equivalent to (*obj_ptr).elt . That is, look up the actual field or method within the object that obj_ptr points to.
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 12:07.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi