Jump to content

[SOLVED] Inheritance from Unigine::Widgets function visibility issue


photo

Recommended Posts

Is it ok what this code is not work?

class Gr {
};

class Foo {
	void a(Bar bar) {
		Gr gr = bar.getGr();
	}
};

class Bar:Unigine::Widgets::Window {
	Gr getGr() { }
};

But this code is work

class Gr {
};

class Foo {
	void a(Bar bar) {
		Gr gr = bar.getGr();
	}
};

class Bar {
	Gr getGr() { }
};
Link to comment

Hi, this is a simple mistake :) The "Foo" class don't knows about "Bar" class

You need declare class "Foo" below a class "Bar", like this:

class Gr {
};

// class Bar declaration
class Bar:Unigine::Widgets::Window {
	Gr getGr() { }
};

// class Foo declaration
class Foo {
	void a(Bar bar) {
		Gr gr = bar.getGr();
	}
};

and all to be alright

Link to comment

Bar need to have pointer to Foo & Foo need to have pointer to Bar. Bar is main class and Foo is utility class. all includes done in Bar class file, so it is not so good to include it after Bar class definition. So we put all our code into Unigine::Widgets namespace & all becomes fine. But anyway, all of this solutions are hacks to prevent this compiler bug. 

Link to comment
×
×
  • Create New...