The Daily Static
  The Daily Static
UF Archives
Register
UF Membership
Ad Free Site
Postcards
Community

Geekfinder
UFie Gear
Advertise on UF

Forum Rules
& FAQ


Username

Password


Create a New Account

 
 

Back to UserFriendly Strip Comments Index

Okay, now my compiler just thinks it's funny. by Llyr2002-09-29 13:54:40
  Nah, it thinks you're funny. by Arcanum2002-09-29 14:00:45
    And, hey, it could be worse. by Arcanum2006-11-19 12:55:59
      Maybe you can figure out what's wrong here. (n/t) by Llyr2002-09-29 14:09:00
        My header file: by Llyr2002-09-29 14:09:36
          And my function definitions. by Llyr2002-09-29 14:10:24
            Slap those two in a project by Llyr2002-09-29 14:11:08
              Well, for starters... by Arcanum2002-09-29 14:31:09
                Where do I have "r" defined elsewhere? by Llyr2002-09-29 14:37:11
                  In your header file. by Arcanum2002-09-29 14:42:09
                    That's the ONLY r I have! by Llyr2002-09-29 14:45:02
                      No... by Arcanum2002-09-29 14:52:59
                        oh. (n/t) by Llyr2002-09-29 15:18:57
                          Okay, revised def. code. by Llyr 2002-09-29 15:23:55
#include <iostream>
#include "math.h"
#include "point.h"

point::point(double xs, double ys) {
    setPoint(xs, ys);
    getPoint();
}

point::~point() {}

point::point &operator+(point p, point q) {
    point t;
    t.setPoint(p.getX()+q.getX(), p.getY()+q.getY());
    return t;
}

point::point &operator-(point p, point q) {
    point t;
    t.setPoint(p.getX()-q.getX(), p.getY()-q.getY());
    return t;
}

point::point &operator*(point p, point q) {
    point t;
    t.setPoint(p.getX()*q.getX(), p.getY()*q.getY());
    return t;
}

point::point &operator/(point p, point q) {
    point t;
    t.setPoint(p.getX()/q.getX(), p.getY()/q.getY());
    return t;
}

bool operator==(point p, point q) {
    if(p.getX()==q.getX()) {
        if(p.getY() == q.getY()) {
        return true;
        }
    }
    else {return false;}
}

bool operator!=(point p, point q) {
    if(p.getX() != q.getX()) {
        if(p.getY() != q.getY()) {
        return true;
        }
    }
    else return false;
}

point::void setX(double q) {x = q;}
point::void setY(double q) {y = q;}
point::void setR(double q) {r = q;}
point::void setTH(double q) {th = q;}

point::void distance(point p, point q) {
    cout << sqrt((p.getX()-q.getX())^2+(p.getY()-q.getY())^2);
}

point::void midpoint(point p, point q) {
    point t;
    t.setPoint((p.getX()+q.getX())/2, (p.getY()+q.getY())/2);
    cout << t;
}

point::void XY2Pol() {
    double q; //for quadrant correction
    r = sqrt(x^2+y^2);
    if(x = 0) {
        th = pi/2;
    }
    if((0 < x) && (0 < y)) {
        q = 0;
    }
    else if((x < 0) && (0 < y)) {
        q = -pi;
    }
    else if((x < 0) && (y > 0)) {
        q = pi;
    }
    else if((0 < x) && (y < 0)) {
        q = -2*pi;
    }
    double qh = arctan(abs(y/x));
    th = abs(qh + q);
}

point::void Pol2XY() {
    x = r*cos(th);
    y = r*sin(th);
}
    

point::void rotate(double ph) {
    XY2Pol();
    double aph = -ph;
    double ath = th;
    ph = aph; //C++ calculates angles counter-clockwise
    th = ath + ph;
    Pol2XY(); //this function is cake with polar coords :)
}
Now tell me what errors you get. I'm getting all this sh*t about "x not defined in this scope" even though x is quite clearly in the header file and "th previously defined here" even though "here" is in an entirely different function... Spencer
[ Reply ]
                            Aren't you getting a whole bunch of by Arcanum2002-09-29 15:43:10
                              Aaahhhh. There we go. (n/t) by Llyr2002-09-29 16:02:07
                                First rule of debugging compile-time errors: by Arcanum2002-09-29 16:06:04
                                heh. (n/t) by Llyr2002-09-29 16:08:51

 

[Todays Cartoon Discussion] [News Index]

Come get yer ARS (Account Registration System) Source Code here!
All images, characters, content and text are copyrighted and trademarks of J.D. Frazer except where other ownership applies. Don't do bad things, we have lawyers.
UserFriendly.Org and its operators are not liable for comments or content posted by its visitors, and will cheerfully assist the lawful authorities in hunting down script-kiddies, spammers and other net scum. And if you're really bad, we'll call your mom. (We're not kidding, we've done it before.)