View Single Post
  #1   Spotlight this post!  
Unread 01-14-2009, 03:43 PM
byteit101's Avatar
byteit101 byteit101 is offline
WPILib maintainer (WPI)
AKA: Patrick Plenefisch
no team (The Cat Attack (Formerly))
Team Role: Programmer
 
Join Date: Jan 2009
Rookie Year: 2009
Location: Worcester
Posts: 699
byteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of light
void* pointer to object in C++

I have been at this for some time now, and this won't compile:
Code:
(function(int data))
void * MyPointer
if (data=0)
{
     Gyro gy(1);
     MyPointer = &gy;
}
if (data=1)
{
     Ultrasonic gy(1);
     MyPointer = &gy;
}
if (etc...
etc...
(function2(int data2))
if (data2=0)
     return MyPointer->GetValue(); //this produces error: 'void*' is not a pointer-to-object type (:eek:)
etc...
You can probably see what i am doing, (accessing different function based on sensor type), and Nothing has worked

Last edited by byteit101 : 01-14-2009 at 03:45 PM. Reason: code bock
Reply With Quote