Help With Outputting data from 2 classes

Hello!
I am working on a school lab and i have encounted a slight problem...

The project is all about using 2 classes, a point class then use that to make a line segment class. For the defalt constructor all you do is generate radom points rather than making it 0,0. here is this sample code

this is for point.h

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
50
51
52
53
54
55
56
57
58
59
60
  #ifndef _POINT_H
#define _POINT_H


#include <stdio.h>      /* NULL */
#include <stdlib.h>     /* rand */
#include <time.h>       /* time */
#include <string.h>

class point
{
public:
	point();
	point(const point &);

	void gen_point(int incomingX, int incomingY);

	int x();
	int y();
	
private:

	int X;
	int Y;

};

point::point()
{
	X = rand() % 101;
	Y = rand() % 101;

	//it is going to generate random points
}

point::point(const point & Object)
{
	X = Object.X;
	Y = Object.Y;
}

void point::gen_point(int incomingX, int incomingY)
{
	X = incomingX;
	Y = incomingY;
}


int point::x()
{
	return X;
}

int point::y()
{
	return Y;
}


#endif 



here is the line_seg.h, some of it is not fully completed but you get the idea.

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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#pragma once

#ifndef _LINESEG_H
#define _LINESEG_H

#include "point.h"
#include <string.h>

class line_seg
{
public:
	//constructors
	line_seg();		//default constructor
	line_seg(const line_seg &);		//copy constructor

	//memeber functions
	
	int show_ax();
	int show_ay();
	int show_bx();
	int show_by();
	


private:


	point Point1;
	point Point2;

};



line_seg::line_seg()
{

	point Point1;
	point Point2;




}

line_seg::line_seg(const line_seg & Object1)
{

	


}


int line_seg::show_ax()
{
	return Point1.x; //error
}

int line_seg::show_ay()
{
	return Point1.y; //error
}

int line_seg::show_bx()
{
	return Point2.x; //error
}

int line_seg::show_by()
{
	return Point2.y; //error
}


#endif 


it is giving me 8 errors in total, all for line_seg.h. one is error C2440 on all of the return statments for lineseg show functions and 4 more for C3867 on the same lines. Please Help!
1
2
3
4
int line_seg::show_by()
{
   return Point2.y; //error
}


This must be return Point2.x(); since you are calling the function x.

The way I set it up was ax is the first point x coordinate and ay is the first point y coordinate and the same for bx and by. The problem is it won't compile and I can't test it at all. Is there any fix I can do that someone sees that I don't?
Have you fixed the problem that Thomas 1965 explained to you?

it won't compile

This is not a helpful description of your problem. Your compiler will be giving you detailed error messages explaining why it failed to compile, and what line number the failure occurred on. What did you hope to achieve by withholding that information from us?
Last edited on
Topic archived. No new replies allowed.