Struct problem

Hi All,

Whilst trying to use an instance of a struct in my class I keep getting this error when I compile:

error: request for member 'Position' in 'obj', which is of non-class type 'MyClass ()()'

In my .imo file I have:

#include "MyClass.h"

void setup()
{
  MyClass obj();
  obj.Position.X = 10;
  obj.Position.Y = 10;
}

void loop()
{
  
}

In my MyClass.cpp is:

#include "MyClass.h"

MyClass::MyClass()
{
}

And in MyClass.h is:

#ifndef MyClass_h
#define MyClass_h

struct MyStruct
{
  int X;
  int Y;
};

class MyClass
{
	public:
		MyStruct Position;

		MyClass();
	protected:
};

#endif

I can't see anything obvious that's wrong with it, all I'm trying to do is set the property of a struct instance but get this error, any ideas?

Thanks!

MyClass obj();  //change this

to

MyClass obj;

Awsome that works, thanks Cybernetician!

Out of curiosity what is the difference between:

MyClass obj();

And

MyClass obj;

?

Thanks again,

Dan

MyClass obj();

This is actually declaring a function called 'obj' that returns a 'MyClass', which is why the error said "MyClass ()()" which is a function type, similar to a function pointer.

MyClass obj;

This declares a variable.

Sorry for late reply i was litle busy in my code

"pYro_65 explains it well"