calling member within a class within a class

I tried to google this before, but I got anything but what I was looking for. Here is a stripped down version of my code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
class color {
public:
    float red;
    float green;
    float blue;
    float alpha;
};

class house {
public:
    color banner;
};

class tenant {
public:
    house faction;

    float render () {
        return tenant::faction::banner::red;    //here is my issue
    }
};


I get an error: 'tenant::faction' is not a class or namespace

I'm sure it's just a beginner's issue, but I'm not able to word it right in google. Thanks in advance.
There are multiple issues here. You don't seem to understand the difference between instance members, static members, and enums. What is render supposed to return?
are you trying to achieve something like this:


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
enum color {

	red,
	green,
	blue,
	alpha,
};

class house {
public:
	color banner;
};

class tenant {
public:
	house faction;

	void render () 
	{
		faction.banner = red;
	}
};

?
I think what he really want to achieve is:
1
2
3
    float render () {
        return faction.banner.red;
    }
oh right.
Either way, OP, read up on all topics L B mentioned.
render () is actually supposed to render the tenant, but it took up lots of code.

@L B: they are all supposed to be instance members, render isn't supposed to
return anything, hence the void return type

@mutexe: I did, and I now feel very enlightened.

@coder777: thanks, this was what I was looking for. Guess I should learn more on classes.
Twist177 wrote:
render isn't supposed to
return anything, hence the void return type
Read your post? You marked it as returning a float and you even used the return statement.
Topic archived. No new replies allowed.