Show Posts
Pages: [1]
1  Using Arduino / Programming Questions / Re: Does Arduino have a problem with pointers to classes? on: February 01, 2013, 04:41:50 pm
Thanks guys. This forum was my last option before candles and chanting, but with your insight I now understand that it wasn't evil spirits after all. I didn't really mean to bother you to explain preprocessing, but thanks for demystifying the issues.
2  Using Arduino / Programming Questions / Re: Does Arduino have a problem with pointers to classes? on: February 01, 2013, 03:39:43 pm
Thanks!

Understanding compilation internals is way above my capabilities (what's preprocessing?  smiley-lol) and I spent way more time than I'll ever admit staring at that snippet of code.

and thanks again
3  Using Arduino / Programming Questions / Re: Does Arduino have a problem with pointers to classes? on: February 01, 2013, 03:20:22 pm
It's not much, but it compiles with the error:
Code:
class foo {
  // whatever
};

void do_something_with_foo(foo *a_new_foo_object) {
  // whatever
}
4  Using Arduino / Programming Questions / Does Arduino have a problem with pointers to classes? on: February 01, 2013, 03:02:51 pm
I hope I'm missing something really simple here. Can anyone see why this won't compile?

I'm trying to create a dynamic queue of "event"s:

Code:
class event {
  public:
    int event_type;
    long time;
    event* next_event;   
};
but the compiler stumbles when I try to define a function that will take a pointer to an "event" as an argument:
Code:
void queue_event(event *new_event_) {
  // code to insert a new event into the queue will come here
};
The compiler doesn't seem to recognize the function definition, claiming:
14: error: variable or field 'queue_event' declared void
14: error: 'event' was not declared in this scope
14: error: 'new_event_' was not declared in this scope

Same result exactly if I use a reference instead of a pointer (event& new_event_). If I change the argument to be a pointer to any basic type (e.g. int* new_event_) it compiles without complaint.

Thanks in advance for any help.

Joe
Pages: [1]