Go to Post Interestingly enough, I saw Shaun open his backpack for a moment during the Newton Alliance selection.... 4 Hours later Team 25 was on Einstein... - thefro526 [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

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Spotlight this post!  
Unread 10-11-2012, 19:42
JPruim JPruim is offline
Registered User
FRC #4014
 
Join Date: Mar 2012
Location: United States
Posts: 5
JPruim is an unknown quantity at this point
Custom Classes?

How would I go about creating a custom class? For example, I want a class that has a digitalInput encapsulated within it. In simple terms, How would I convert my existing LimitSwitch class (https://github.com/itguy51/FRC4014-2...mitSwitch.java) into C++? I have never actually used C++ in Object-Oriented programming other than simple things like in Visual Studio for demonstrations. I guessed how, and got this:
Code:
class limitSwitch
{
	DigitalInput di;
	limitSwitch::limitSwitch(UINT32 port){
		di(port);
	}
	bool limitSwitch::getState(){
		return di.Get() == 1;
	}
};
which is FULL of errors, there are more lines in the error log than there are in the cpp file. I get "Error: Expected ')' before "port"" and am confused because that makes no sense. I want to pass an argument to the constructor so that it assigns the DigitalInput to the initialized port.
getState is supposed to return true/false based on the state of the switch.
Reply With Quote
 


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 18:18.

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