Classes and Memeber problem

Hello Everyone!
Can Anyone Help me please?
So Im trying to get a value from a class to another class.
So this one complies but does not show what i want.
idk what is wrong and couldnt figure it out for like hours. :(
in the main it lets user to make two points and from that it creates
offices.
And im trying to get a,x,y values from Office and then use it in the Courses.
PS this is just a part of my program that i dont get.
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
///From This///
Office::Office() {
	office_address = 0;
	location = Point(0.0, 0.0);
}

Office::Office(int new_office_address, Point new_location) {
	office_address = new_office_address;
	location = new_location;
	a = office_address;
	x = location.get_x();
	y = location.get_y();
}
///TO HERE///
Course::Course(){
	Course fisrt;
	Course last;
	int num_offices = 2;
	double x1,x2,y1,y2;
	int a1,a2;
}
Course::Course(Office one, Office two, int new_num_offices){
	Office first = one;
	Office second = two;
	new_num_offices = num_offices;
	x1 = first.x;
	y1 = first.y;
	x2 = second.x;
	y2 = second.y;
	a1 = first.a;
	a2 = second.a;
}

void Course::plot() {
	int n = num_offices;
	for (int i = 1; i <= n-2; i++)
	{
		Point location_plot( (x2-x1)/(n-1)*(double)i, (y2-y1)/(n-1)*(double)i );
		int address_plot = a1 + ((a2-a1)/(n-1)*i);
		Office h_plot(address_plot, location_plot);
		h_plot.draw();
	}
}
Last edited on
Are the data members of Office private? If so, that's good - they probably should be private. But if you want other classes to be able to get the values of those data members, then you'll need to write some accessor methods on the Office class to obtain them.

Also, what's going on in your constructor for Course? You declare a load of local variables, and initialise one of them, but you never use them.
> Also, what's going on in your constructor for Course?
stack overflow. The default constructor is creating object of that class using the default constructor.

@OP
http://www.cplusplus.com/forum/articles/40071/#msg216313
http://www.cplusplus.com/forum/articles/40071/#msg218019
Topic archived. No new replies allowed.