problem passing class pointer to function

Hi, I'm having a problem with passing class pointers to non class function as in the code fragment below

void setup() { // put your setup code here, to run once:

}

class TTest { public: void junk(TTest *x); };

void TTest::junk(TTest *x) { }

void Func(TTest *x) {

}

void loop() { // put your main code here, to run repeatedly:

}

It fails to compile stating that TTest is not declared in this scope on the line "void Func(TTest *x)" and I cant see why.

Is this a restriction in C++ not being able to passs a class pointer to a non class function ?

I would have thought this would be possible (its easy enough in object pascal).

It's caused by the mangling the IDE does for you. Create a TTest.cpp and a TTest.h tab and populate them with your class code as in any cpp program. Add #include "TTest.h" at the top of the ino & cpp tabs.

Thanks heaps wildbill.

That worked a treat. I guess I need to learn more about the mangling. I wouldn't have thought it would make a difference being in the same file, biut it obviously does.

Thanks again, Andrew

It's just that the IDE creates function prototypes for you. So it created a prototype for Func at the top of the ino file before the class was defined.