View Single Post
  #3   Spotlight this post!  
Unread 12-11-2012, 12:32
Greg McCoy's Avatar
Greg McCoy Greg McCoy is offline
boiler up!
FRC #3940 (CyberTooth)
Team Role: Engineer
 
Join Date: Feb 2002
Rookie Year: 2002
Location: Kokomo, IN
Posts: 484
Greg McCoy has a reputation beyond reputeGreg McCoy has a reputation beyond reputeGreg McCoy has a reputation beyond reputeGreg McCoy has a reputation beyond reputeGreg McCoy has a reputation beyond reputeGreg McCoy has a reputation beyond reputeGreg McCoy has a reputation beyond reputeGreg McCoy has a reputation beyond reputeGreg McCoy has a reputation beyond reputeGreg McCoy has a reputation beyond reputeGreg McCoy has a reputation beyond repute
Send a message via AIM to Greg McCoy
Re: What does the ampersand (&) mean in errors?

Initialization in C++ is a little tricky when you're using objects as member variables.

When you declare the limitSwitch(UINT32) constructor, the compiler is trying to use the default constructor to create the di object, before it even looks at your constructor body. The DigitalInput class doesn't have a default (or zero-argument) constructor, so the compiler is giving you a list of the constructors which are available. You can tell the compiler to use another constructor by using an "initialization list."

I think what you mean to do is this:

Code:
#include "WPILib.h"

class limitSwitch
{
	DigitalInput di; // robot drive system

public:
	limitSwitch(UINT32 p) : di (p) { }
};

Hope this helps! Here are some links for more information:
Reply With Quote