Go to Post Here, and in general, avoid jumping to conclusions without research. This will serve you well in life. - DonRotolo [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 25-06-2009, 16:58
Happyisgood Happyisgood is offline
Registered User
FRC #3161 (Tronic Titans)
Team Role: College Student
 
Join Date: May 2009
Rookie Year: 2009
Location: Canada
Posts: 23
Happyisgood is an unknown quantity at this point
Issues with a header file

Hey!

Don't laugh at me for this, I'm having issues with my robot class.

I'm declaring a robot class in a custom header file and then including it in my main file. For some reason I can't get the functions to work in the main file.

This is my first time attempting this so I know it's a stupid mistake but I have no clue what to do!

Attached are the .cpp and .h files!

Thanks!
Nick

NOTE: Its an alteration of the original Iterative default code sample posted on this site earlier, my thanks to whoever did that!
Attached Files
File Type: cpp MyRobot.cpp (1.8 KB, 461 views)
File Type: h RobotClass.h (572 Bytes, 463 views)
__________________
2009 - Waterloo Regional - Regional Finalist
2009 - Waterloo Regional - Engineering Inspiration Award


________________________

2009 Team Member 1334
Reply With Quote
  #2   Spotlight this post!  
Unread 26-06-2009, 01:53
Pat Fairbank's Avatar
Pat Fairbank Pat Fairbank is offline
Circuit Breaker
FRC #0254 (The Cheesy Poofs)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2001
Location: San Jose, CA
Posts: 2,131
Pat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond repute
Send a message via MSN to Pat Fairbank
Re: Issues with a header file

One issue immediately jumps out to me. You're declaring your Victors, Relay and Joystick as objects in the header file, but initializing them in the constructor as if they were pointers. You need to either declare them as pointers (e.g. Victor* leftDrive) or fix your constructor to have an initialization list:
Code:
IterativeDefaultRobot::IterativeDefaultRobot(void) :
leftDrive(1), rightDrive(2), driveStick(1), testspike(1)
{
...
}
If you're having problems apart from that, it would be great if you could post the relevant compiler output.
__________________
Patrick Fairbank
Team 254 | Mentor (2012-)
Team 1503 | Mentor (2007-2011)
Team 296 | Alumnus (2001-2004) | Mentor (2005-2006)

patfairbank.com
Reply With Quote
  #3   Spotlight this post!  
Unread 26-06-2009, 04:09
RyanCahoon's Avatar
RyanCahoon RyanCahoon is offline
Disassembling my prior presumptions
FRC #0766 (M-A Bears)
 
Join Date: Dec 2007
Rookie Year: 2007
Location: Mountain View
Posts: 689
RyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond repute
Re: Issues with a header file

A couple of things I noticed:

-- Try including the RobotClass.h header in MyRobot.cpp. The compiler often times needs the type definition to work off of. It can't hurt in any case.
-- Your class is called IterativeDefaultRobot in MyRobot.cpp, but IterativeRobotDefault in RobotClass.h (make sure to change your constructor name as well)
-- testspike has a lowercase s in MyRobot.cpp and an uppercase S in RobotClass.h
-- The issue that Pat pointed out is true, but also you're using a dereferencing operator (->) on an object instead of a member access operator (.). Looks like you actually want to declare them as pointers in your header, but then make sure to add a destructor in order to delete them.

Good luck,
--Ryan
__________________
FRC 2046, 2007-2008, Student member
FRC 1708, 2009-2012, College mentor; 2013-2014, Mentor
FRC 766, 2015-, Mentor
Reply With Quote
  #4   Spotlight this post!  
Unread 26-06-2009, 10:52
Happyisgood Happyisgood is offline
Registered User
FRC #3161 (Tronic Titans)
Team Role: College Student
 
Join Date: May 2009
Rookie Year: 2009
Location: Canada
Posts: 23
Happyisgood is an unknown quantity at this point
Re: Issues with a header file

Thanks guys, I made many of those changes and it worked. For personal ease I'm going to stick with my one-file source for now but that will be great when I start programming more advanced things later!

Thanks!
Nick
__________________
2009 - Waterloo Regional - Regional Finalist
2009 - Waterloo Regional - Engineering Inspiration Award


________________________

2009 Team Member 1334
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Wind River header issues dpeterson3 C/C++ 6 11-01-2009 18:17
Header File Missing BloodSoakedTear Programming 1 26-02-2006 16:54
Error in header file p18f8520.h !!! RbtGal1351 Programming 3 17-01-2005 16:03
Header File error message Mike Yan Programming 2 09-02-2004 11:31
Needing A header file jweric Programming 19 23-01-2004 10:25


All times are GMT -5. The time now is 02:52.

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