I have a problem with my code. What I am doing is making a linked list of points (x,y). I want to ask the user for points (as many as they want to add) then add them into a linked list. I also want to sort the points by their x value. Finally I want to print the points in the list. So far I have the linked list code and the point code. What I need help with is using those to
1) Ask the user to enter as many points as they want
2) Add the points entered by the user into the linked list
3) Sort the list by x value
4) Display the points in the linked list
I have tried many things to get this to work, but I keep getting errors like no << operator for Point when I try to print the linked list. Also, I don't think I'm retrieving the list points from the user correctly, it seems to only be taking x values (not sure how to let the user enter points). Although I want to sort by x value I really want to just get the points into the linked list and displayed first then I think i can figure out how to sort them.
So please if anyone could take a look at my code and show me where I am going wrong and how to do what I am asking with my current code for the linked list and point classes. I really just need someone to show me how to ask the user for points then put them in the linked list and print it.
I've attached my four program files (linkedList.h, LinkedPoints.cpp, Point.h, and Point.cpp).
(1) linkedList.h is the linked list class and its methods.
(2) LinkedPoints.cpp is my main() where I have attempted to ask the user for points, enter the points into the linked list and print it, but it isn't done right.
(3) Point.h is my point class.
(4) Point.cpp has the methods and constructors for Point.h.
I really need specific code help with this because I understand what I have to do already, but I keep running into little problems with the actual code.
Thanks in advance for any help.
For those that don't want to download the files I'll post the code here, except for linkedList.h because it is pretty large, but also the most important. At the very bottom you can download linkedList.h and the others if you want.
using namespace std;
Point(int x, int y);
void pointCoord(int x, int y);
void pointDraw(int x, int y);
void setX(int xVal);
void setY(int yVal);
void print(int x, int y);
x = 0;
y = 0;
Point::Point(int x, int y)
x = x;
y = y;
void Point::pointCoord(int x, int y)
output_handle = GetStdHandle(STD_OUTPUT_HANDLE);
pos.X = x;
pos.Y = y;
//Draw at coordinates once found
void Point::pointDraw(int x, int y)
cout << "<-Coord Is Here\n";
void Point::setX(int xVal)
x = xVal;
void Point::setY(int yVal)
y = yVal;
void Point::print(int x, int y)
cout << x << "," << y << endl;
// LinkedPoints.cpp : Defines the entry point for the console application.
int _tmain(int argc, _TCHAR* argv)
int x = 0;
int y = 0;
Point p1(x, y);
cout<<"1) Type two numbers to make a coordinate."
"\n2) Use the format (XX YY) only spacing the numbers not using a comma."
"\n3) Then press Enter to add the coordinate to the list."
"\n4) When finished adding to the list type -9999 and press Enter."
cin >> x, y;
while(x != -9999)//execution number for list creation
list1.insertLast(p1);//insert info into the list as long as -9999 isn't entered
cin >> x, y;