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
#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.
#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!
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?