Round 3, Heads Up
Moderator: Moderators
-
- Inmate
- Posts: 128
- Joined: Sun Jan 27, 2002 4:17 pm
Round 3, Heads Up
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>        private:<br>                int _x, _y;<br>        public: <br>                Point() { _x = _y = 0;} <br>                Point(int x, int y) <br>                {<br>                        _x = x; <br>                        _y = y; <br>                } <br>                ~Point() {} <br>                void setPoint(int x,int y) {_x = x; _y = y;} <br>                void setX(int x){_x = x;} <br>                void setY(int y){_y = y;} <br>                Point getPoint(){return *this;}<br>                int getX(){return _x;}<br>                int getY(){return _y;}<br>                void showPoint(){<br>                cout << "Point: X = " << _x << "; Y = " << _y << endl;<br>                } <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>        private:<br>                Point beginning;<br>                Point ending;<br>                double length;<br>                void calcLength ();<br>        public:<br>                //Constructors<br>                Line ();<br>                Line (int, int);<br>                Line (int, int, int, int);<br>                void setPoints (int, int, int, int);<br>                void setPoints (Point, Point);<br>                void setBeginningPoint (int, int);<br>                void setBeginningPoint (Point);<br>                Point getBeginningPoint ();<br>                void setEndingPoint (int, int);<br>                void setEndingPoint (Point);<br>                Point getEndingPoint ();<br>                double getLength ();<br>                void showLine ();<br>};<br>#endif<br>/****************************************************************/<br>Line::Line ()<br>{<br>        beginning.setPoint (0, 0);<br>        ending.setPoint (0, 0);<br>        length = 0;<br>}<br>/****************************************************************/<br>Line::Line (int endx, int endy)<br>{<br>        beginning.setPoint (0, 0);<br>        ending.setPoint (endx, endy);<br>        calcLength ();<br>}<br>/****************************************************************/<br>Line::Line (int beginx, int beginy, int endx, int endy)<br>{<br>        beginning.setPoint (beginx, beginy);<br>        ending.setPoint (endx, endy);<br>        calcLength ();<br>}<br>/****************************************************************/<br>void Line::setPoints (int beginx, int beginy, int endx, int endy)<br>{<br>        beginning.setX (beginx);<br>        beginning.setY (beginy);<br>        ending.setX (endx);<br>        ending.setY (endy);<br>}<br>/****************************************************************/<br>void Line::setPoints (Point begin, Point end)<br>{<br>        beginning = begin;<br>        ending = end;<br>}<br>/****************************************************************/<br>void Line::setBeginningPoint (int beginx, int beginy)<br>{<br>        beginning.setX (beginx);<br>        beginning.setY (beginy);<br>}<br>/****************************************************************/<br>void Line::setBeginningPoint (Point begin)<br>{<br>        beginning = begin;<br>}<br>/****************************************************************/<br>Point Line::getBeginningPoint ()<br>{<br>        beginning.getPoint ();<br>}<br>/****************************************************************/<br>void Line::setEndingPoint (int endx, int endy)<br>{<br>        ending.setX (endx);<br>        ending.setY (endy);<br>}<br>/****************************************************************/<br>void Line::setEndingPoint (Point end)<br>{<br>        ending = end;<br>}<br>/****************************************************************/<br>Point Line::getEndingPoint ()<br>{<br>        ending.getPoint ();<br>}<br>/****************************************************************/<br>double Line::getLength ()<br>{<br>        return length;<br>}<br>/****************************************************************/<br>void Line::showLine ()<br>{<br>        cout << "Beginning " << beginning.showPoint;<br>        cout << "Ending " << ending.showPoint;<br>}<br>/****************************************************************/<br>void Line::calcLength ()<br>{<br>        double difX = 0;<br>        double difY = 0;<br>        difX = ending.getX - beginning.getX;<br>        difY = ending.getY - beginning.getY;<br>        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>        double sumLength;<br>        Line l1,l2(1,1,4,5),l3(3,4),l4,l5,l6,l7;<br>        cout.precision(2);<br>        cout.setf(ios::fixed|ios::showpoint);<br>        cout << "This program will create lines.\n\n";<br>        cout << "This is line 1\n";<br>        l1.showLine();<br>        cout << "This is line 2\n";<br>        l2.showLine();<br>        cout << "This is line 3\n";<br>        l3.showLine();<br>        l4.setPoints(1,1,4,5);<br>        cout << "This is line 4\n";<br>        l4.showLine();<br>        l5.setBeginningPoint(2,2);<br>        l5.setEndingPoint(5,6);<br>        cout << "This is line 5\n";<br>        l5.showLine();<br>        l6.setPoints(l2.getBeginningPoint(),l2.getEndingPoint());<br>        cout << "This is line 6\n";<br>        l6.showLine();<br>        l7.setBeginningPoint(l5.getBeginningPoint());<br>        l7.setEndingPoint(l5.getEndingPoint());<br>        cout << "This is line 7\n";<br>        l7.showLine();<br>        sumLength = l1.getLength() + l2.getLength() + l3.getLength() +<br>                                l4.getLength() + l5.getLength() + l6.getLength() +<br>                                l7.getLength();<br>        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>
-
- Inmate
- Posts: 128
- Joined: Sun Jan 27, 2002 4:17 pm
Re: Round 2 , Heads Up
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>
-
- Inmate
- Posts: 966
- Joined: Thu Jan 17, 2002 5:26 pm
Re: Round 2 , Heads Up
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>
- XMEN Iceman
- Moderator
- Posts: 2386
- Joined: Thu Nov 18, 1999 1:25 pm
Re: Round 2 , Heads Up
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>
- XMEN Gambit
- Site Admin
- Posts: 4122
- Joined: Thu Nov 18, 1999 12:00 am
Re: Round 2 , Heads Up
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>