"class has no member named"

May 12, 2011 at 5:41pm
I'm getting a well-known error that should be pretty easy to solve:

‘class GeometricObject’ has no member named ‘get_material_ptr’


However, I can't understand why this would be the case. Here's part of GeometricObject.h:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

#ifndef GEOMETRICOBJECT
#define GEOMETRICOBJECT

#include "Material.h"

class GeometricObject {
	public:
		GeometricObject(void);
...................
		Material* get_material_ptr(void) const;
..................
};

#endif 


And here's the implementation:
1
2
3
Material* GeometricObject::get_material_ptr(void) const {
	return material_ptr;
}


I have a feeling that the answer is pretty ridiculous, and I'm frankly a bit scared to even post this in case it is, but I just don't get this:p

Fafner
May 12, 2011 at 5:42pm
Where are you using it?
May 12, 2011 at 5:47pm
This is the line that causes the error:

sr.material_ptr = objects[j]->get_material_ptr();

The class this line is from includes both GeometricObject and and the class of which sr is an instance.
Last edited on May 12, 2011 at 5:49pm
May 12, 2011 at 5:56pm
Could you show us the declaration/definition of objects?
May 12, 2011 at 5:57pm
Sure:
std::vector<GeometricObject*> objects;

This is in the same class that contains the erroneous line.
Last edited on May 12, 2011 at 5:59pm
May 12, 2011 at 6:10pm
I don't see any problem here.

Try cleaning the solution and rebuilding.
May 12, 2011 at 6:16pm
Ok, I did a completely clean build, and the error remains. This is really weird:p
May 12, 2011 at 7:14pm
Rewrite appeared to be the only option, fixed now:)
Topic archived. No new replies allowed.