Multiple inherance

Hey,
I want to give an instance of the class c the y value of an instance of the class b.
Who can I do this if I want to do it with pointers?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
  class a {
protected:
	int x;
	
public:
	a(int);
};

a::a(int _x) {
	x = _x;
}

class b : public a {
protected:
	int y;

public:
	b(int, int);
	int get_y() {
		return y;
	}
};

b::b(int _x, int _y) : a(_x) {
	y = _y;
}

class c : public b {
private:
	int z;

public:
	c(int, int, int);
	void chng_y(b *member_b) {
		y = get_y()->member_b;
	}
};

c::c(int _x, int _y, int _z) : b(_x, _y) {
	z = _z;
}



int main()
{
    return 0;
}
Topic archived. No new replies allowed.