Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   C/C++ (http://www.chiefdelphi.com/forums/forumdisplay.php?f=183)
-   -   Invalid Conversion (http://www.chiefdelphi.com/forums/showthread.php?t=90376)

ehlochbr 29-01-2011 00:30

Invalid Conversion
 
Hi everyone,

This is probably an easy one but I'm just not seeing the answer. I'm trying to incorporate code for the IR sensors and everything seems fine except for one little error that says "invalid conversion from "int" to "DigitalInput."

Here's a snapshot of some of the code.

Code:

class RobotDemo : public SimpleRobot
{
        RobotDrive myRobot; // robot drive system
        Gamepad controller;
        Jaguar one;
        Jaguar two;
        Jaguar three;
        Jaguar four;
        DigitalInput *left;                        // digital inputs for line tracking sensors
        DigitalInput *middle;
        DigitalInput *right;
        DriverStation *ds;
        AxisCamera& camera;
       
       
public:
        RobotDemo(void):
                myRobot(9, 10, 2, 1),        // these must be initialized in the same order
                controller(1),
                one(9),
                two(10),
                three(2),
                four(1),
                left(1),
                middle(2),
                right(3),
                ds(DriverStation::GetInstance()),
                camera(AxisCamera::GetInstance())
               
        {  <------- ERROR HERE

                GetWatchdog().SetExpiration(0.1);

Thanks for your help!

shandrin 29-01-2011 02:29

Re: Invalid Conversion
 
The problem is that you're declaring pointers to DigitalInputs, and then trying to initialize them in the initialization list. You either need to declare them as actual DigitalInput objects (no *) or instead of left(1), middle(2), right(3), you need to have inside the constructor (where you note "error here"):
left = new DigitalInput(1);
middle = new DigitalInput(2);
right = new DigitalInput(3);

Hope that helps!


All times are GMT -5. The time now is 17:45.

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