Round 3, Heads Up

Wanna understand E=mc2, English grammer, or maybe just build a computer? We can help!

Moderator: Moderators

Post Reply
LoSTimberWolf
Inmate
Posts: 128
Joined: Sun Jan 27, 2002 4:17 pm

Round 3, Heads Up

Post by LoSTimberWolf »

Third Program, three files, two are headers and one is main. Objective is to create an object that uses class Point to create a line. Here is class point:<br><br>// point.h<br>#ifndef POINT_H<br>#define POINT_H<br>#include <iostream.h><br>// Point class declaration.<br>class Point { <br>&nbsp &nbsp &nbsp &nbsp private:<br>&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp int _x, _y;<br>&nbsp &nbsp &nbsp &nbsp public: <br>&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp Point() { _x = _y = 0;} <br>&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp Point(int x, int y) <br>&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp {<br>&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp _x = x; <br>&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp _y = y; <br>&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp } <br>&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp ~Point() {} <br>&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp void setPoint(int x,int y) {_x = x; _y = y;} <br>&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp void setX(int x){_x = x;} <br>&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp void setY(int y){_y = y;} <br>&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp Point getPoint(){return *this;}<br>&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp int getX(){return _x;}<br>&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp int getY(){return _y;}<br>&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp void showPoint(){<br>&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp cout << "Point: X = " << _x << "; Y = " << _y << endl;<br>&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp } <br>}; <br>#endif<br><br><br>Here is the class I have to make, Line:<br><br>#ifndef LINE_H<br>#define LINE_H<br>#include <iostream.h><br>#include <math.h><br>#include "point.h"<br>//Line Class declaration<br>class Line <br>{<br>&nbsp &nbsp &nbsp &nbsp private:<br>&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp Point beginning;<br>&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp Point ending;<br>&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp double length;<br>&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp void calcLength ();<br>&nbsp &nbsp &nbsp &nbsp public:<br>&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp //Constructors<br>&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp Line ();<br>&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp Line (int, int);<br>&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp Line (int, int, int, int);<br>&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp void setPoints (int, int, int, int);<br>&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp void setPoints (Point, Point);<br>&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp void setBeginningPoint (int, int);<br>&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp void setBeginningPoint (Point);<br>&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp Point getBeginningPoint ();<br>&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp void setEndingPoint (int, int);<br>&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp void setEndingPoint (Point);<br>&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp Point getEndingPoint ();<br>&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp double getLength ();<br>&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp void showLine ();<br>};<br>#endif<br>/****************************************************************/<br>Line::Line ()<br>{<br>&nbsp &nbsp &nbsp &nbsp beginning.setPoint (0, 0);<br>&nbsp &nbsp &nbsp &nbsp ending.setPoint (0, 0);<br>&nbsp &nbsp &nbsp &nbsp length = 0;<br>}<br>/****************************************************************/<br>Line::Line (int endx, int endy)<br>{<br>&nbsp &nbsp &nbsp &nbsp beginning.setPoint (0, 0);<br>&nbsp &nbsp &nbsp &nbsp ending.setPoint (endx, endy);<br>&nbsp &nbsp &nbsp &nbsp calcLength ();<br>}<br>/****************************************************************/<br>Line::Line (int beginx, int beginy, int endx, int endy)<br>{<br>&nbsp &nbsp &nbsp &nbsp beginning.setPoint (beginx, beginy);<br>&nbsp &nbsp &nbsp &nbsp ending.setPoint (endx, endy);<br>&nbsp &nbsp &nbsp &nbsp calcLength ();<br>}<br>/****************************************************************/<br>void Line::setPoints (int beginx, int beginy, int endx, int endy)<br>{<br>&nbsp &nbsp &nbsp &nbsp beginning.setX (beginx);<br>&nbsp &nbsp &nbsp &nbsp beginning.setY (beginy);<br>&nbsp &nbsp &nbsp &nbsp ending.setX (endx);<br>&nbsp &nbsp &nbsp &nbsp ending.setY (endy);<br>}<br>/****************************************************************/<br>void Line::setPoints (Point begin, Point end)<br>{<br>&nbsp &nbsp &nbsp &nbsp beginning = begin;<br>&nbsp &nbsp &nbsp &nbsp ending = end;<br>}<br>/****************************************************************/<br>void Line::setBeginningPoint (int beginx, int beginy)<br>{<br>&nbsp &nbsp &nbsp &nbsp beginning.setX (beginx);<br>&nbsp &nbsp &nbsp &nbsp beginning.setY (beginy);<br>}<br>/****************************************************************/<br>void Line::setBeginningPoint (Point begin)<br>{<br>&nbsp &nbsp &nbsp &nbsp beginning = begin;<br>}<br>/****************************************************************/<br>Point Line::getBeginningPoint ()<br>{<br>&nbsp &nbsp &nbsp &nbsp beginning.getPoint ();<br>}<br>/****************************************************************/<br>void Line::setEndingPoint (int endx, int endy)<br>{<br>&nbsp &nbsp &nbsp &nbsp ending.setX (endx);<br>&nbsp &nbsp &nbsp &nbsp ending.setY (endy);<br>}<br>/****************************************************************/<br>void Line::setEndingPoint (Point end)<br>{<br>&nbsp &nbsp &nbsp &nbsp ending = end;<br>}<br>/****************************************************************/<br>Point Line::getEndingPoint ()<br>{<br>&nbsp &nbsp &nbsp &nbsp ending.getPoint ();<br>}<br>/****************************************************************/<br>double Line::getLength ()<br>{<br>&nbsp &nbsp &nbsp &nbsp return length;<br>}<br>/****************************************************************/<br>void Line::showLine ()<br>{<br>&nbsp &nbsp &nbsp &nbsp cout << "Beginning " << beginning.showPoint;<br>&nbsp &nbsp &nbsp &nbsp cout << "Ending " << ending.showPoint;<br>}<br>/****************************************************************/<br>void Line::calcLength ()<br>{<br>&nbsp &nbsp &nbsp &nbsp double difX = 0;<br>&nbsp &nbsp &nbsp &nbsp double difY = 0;<br>&nbsp &nbsp &nbsp &nbsp difX = ending.getX - beginning.getX;<br>&nbsp &nbsp &nbsp &nbsp difY = ending.getY - beginning.getY;<br>&nbsp &nbsp &nbsp &nbsp length = sqrt( pow(difX, 2) + pow(difY, 2));<br>}<br>/****************************************************************/<br><br>Just so you can see the entire program, here is main:<br><br>// lineMain.cpp<br>#include <iostream.h><br>#include "point.h"<br>#include "line.h"<br>void main()<br>{<br>&nbsp &nbsp &nbsp &nbsp double sumLength;<br>&nbsp &nbsp &nbsp &nbsp Line l1,l2(1,1,4,5),l3(3,4),l4,l5,l6,l7;<br>&nbsp &nbsp &nbsp &nbsp cout.precision(2);<br>&nbsp &nbsp &nbsp &nbsp cout.setf(ios::fixed|ios::showpoint);<br>&nbsp &nbsp &nbsp &nbsp cout << "This program will create lines.\n\n";<br>&nbsp &nbsp &nbsp &nbsp cout << "This is line 1\n";<br>&nbsp &nbsp &nbsp &nbsp l1.showLine();<br>&nbsp &nbsp &nbsp &nbsp cout << "This is line 2\n";<br>&nbsp &nbsp &nbsp &nbsp l2.showLine();<br>&nbsp &nbsp &nbsp &nbsp cout << "This is line 3\n";<br>&nbsp &nbsp &nbsp &nbsp l3.showLine();<br>&nbsp &nbsp &nbsp &nbsp l4.setPoints(1,1,4,5);<br>&nbsp &nbsp &nbsp &nbsp cout << "This is line 4\n";<br>&nbsp &nbsp &nbsp &nbsp l4.showLine();<br>&nbsp &nbsp &nbsp &nbsp l5.setBeginningPoint(2,2);<br>&nbsp &nbsp &nbsp &nbsp l5.setEndingPoint(5,6);<br>&nbsp &nbsp &nbsp &nbsp cout << "This is line 5\n";<br>&nbsp &nbsp &nbsp &nbsp l5.showLine();<br>&nbsp &nbsp &nbsp &nbsp l6.setPoints(l2.getBeginningPoint(),l2.getEndingPoint());<br>&nbsp &nbsp &nbsp &nbsp cout << "This is line 6\n";<br>&nbsp &nbsp &nbsp &nbsp l6.showLine();<br>&nbsp &nbsp &nbsp &nbsp l7.setBeginningPoint(l5.getBeginningPoint());<br>&nbsp &nbsp &nbsp &nbsp l7.setEndingPoint(l5.getEndingPoint());<br>&nbsp &nbsp &nbsp &nbsp cout << "This is line 7\n";<br>&nbsp &nbsp &nbsp &nbsp l7.showLine();<br>&nbsp &nbsp &nbsp &nbsp sumLength = l1.getLength() + l2.getLength() + l3.getLength() +<br>&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp l4.getLength() + l5.getLength() + l6.getLength() +<br>&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp l7.getLength();<br>&nbsp &nbsp &nbsp &nbsp cout << "The sum of the line lengths is: " << sumLength << endl;<br>}<br><br><br>Current problems are in the final two functions defined in Line.h:<br><br>error C2679: binary '<<' : no operator defined which takes a right-hand operand of type '' (or there is no acceptable conversion)<br>error C2679: binary '<<' : no operator defined which takes a right-hand operand of type '' (or there is no acceptable conversion)<br>error C2296: '-' : illegal, left operand has type 'int (__thiscall Point::*)(void)'<br>error C2297: '-' : illegal, right operand has type 'int (__thiscall Point::*)(void)'<br>error C2296: '-' : illegal, left operand has type 'int (__thiscall Point::*)(void)'<br>error C2297: '-' : illegal, right operand has type 'int (__thiscall Point::*)(void)'<br>Error executing cl.exe.<br> <p></p><i></i>
LoSTimberWolf
Inmate
Posts: 128
Joined: Sun Jan 27, 2002 4:17 pm

Re: Round 2 , Heads Up

Post by LoSTimberWolf »

I just got it all figured out. I guess taking my glasses off and looking at a blur workes cause I got it working. Since I got a thread here anyways, how about I pop a question. What would prevent the copying of one hard drive to another on one system? My Dad got his 20gig hard drive back after sending it in cause it was not working right, and when he copies his current HD over to it, it does not copy it all so it will not boot off the 20gig HD. <p></p><i></i>
BlackRider
Inmate
Posts: 966
Joined: Thu Jan 17, 2002 5:26 pm

Re: Round 2 , Heads Up

Post by BlackRider »

dunno... maybe if you wanna boot off of it you have to copy the image and not just the files that windows sees... shrug... I have no clue BC I've never had more than 1 HD in my comp <!--EZCODE EMOTICON START :( --><img src=http://www.ezboard.com/images/emoticons/frown.gif ALT=":("><!--EZCODE EMOTICON END--> <p><!--EZCODE FONT START--><span style="color:red;font-size:large;">C</span><!--EZCODE FONT END--><!--EZCODE FONT START--><span style="color:orange;font-size:large;">O</span><!--EZCODE FONT END--><!--EZCODE FONT START--><span style="color:green;font-size:large;">L</span><!--EZCODE FONT END--><!--EZCODE FONT START--><span style="color:blue;font-size:large;">O</span><!--EZCODE FONT END--><!--EZCODE FONT START--><span style="color:indigo;font-size:large;">R</span><!--EZCODE FONT END--><!--EZCODE FONT START--><span style="color:violet;font-size:large;">S</span><!--EZCODE FONT END--><!--EZCODE FONT START--><span style="color:pink;font-size:xx-large;">!</span><!--EZCODE FONT END--></p><i></i>
User avatar
XMEN Iceman
Moderator
Posts: 2386
Joined: Thu Nov 18, 1999 1:25 pm

Re: Round 2 , Heads Up

Post by XMEN Iceman »

Make sure you FDisk it to create the partition first. Then Format it. <br><br>I STRONGLY recommend Symantec Ghost. You don't have to fdisk or format then. You just put the two drives in a system. Boot up with a system disk, then run Ghost. It will copy and create the mirror image on any size drive. <!--EZCODE EMOTICON START :) --><img src=http://www.ezboard.com/images/emoticons/smile.gif ALT=":)"><!--EZCODE EMOTICON END--> <p><table border="0"><tr><td><embed align="left" src="http://www.thzclan.com/avatars/ezice.swf" menu="false" quality="high" bgcolor="#000000" width="217" height="166" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/shockwave/dow ... <td><table border="0" style='Filter: Shadow(Color=#BB1403,Direction=255)'><tr><td><span class='usertitle'>XMEN Iceman [DTM]<br>Founder and Leader of the Base Tribes XMEN Clan<br>Proud member of the Dragon Talon Mercenaries teamplayers Guild<br>Member of THZ - The Hounds of Zeus clan<br><br>"You weren't much of a challenge" - T2 bot after killing Iceman<br><br>- click on avatar for links - no, not sausage links!</span></td></tr></table></td></tr></table></p><i></i>
User avatar
XMEN Gambit
Site Admin
Posts: 4122
Joined: Thu Nov 18, 1999 12:00 am

Re: Round 2 , Heads Up

Post by XMEN Gambit »

Yeah, you can't just copy the files and expect it to boot. The new drive needs to have an active, bootable partition, first of all, which you have to do with FDISK outside of windows. Then it has to be formatted, and certain system files have to be placed into exact physical locations on the disk, which you normally do with the "format /s d:" command or the "system d:" command. (assuming d: is the new drive)<br>After all of that, the windows operating system needs to be installed, but that CAN actually be copied over with everything else assuming that just the hard drive is changing and not any other hardware. <p><!--EZCODE IMAGE START--><img src="http://www.xmenclan.org/xmengambit.gif"/><!--EZCODE IMAGE END--><br>XMEN member<br>Card-carrying DTM<br>OKL Fish-napper<br><br>Though a program be but three lines long, someday it will have to be maintained.<br><!--EZCODE ITALIC START--><em> The Tao of Programming</em><!--EZCODE ITALIC END--></p><i></i>
Image
Post Reply