105 errors on build but none of them point to a spot in the file T.T
Nov 30, 2011 at 9:23pm UTC
Hey,
I am working on a project and when I build the project it gives me 105 errors and when I go to them it doesn't tell me where in the program the error occurs could use some help.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#include <iostream>
#include "circle2d.h"
using namespace std;
void main()
{
Circle2d c1(2,2,5.5);
Circle2d c2(2,2,5.5);
Circle2d c3(4,5,10.5);
cout<<c1.getArea()<<endl;
c1.contains(c2);
c1.overlaps(c3);
}
I think the problem is in this section the errors tell me that it is related to circle 2d
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
#include "circle2d.h"
#include <math.h>
#include <iostream>
using namespace std;
Circle2d::Circle2d(){
x=0;
y=0;
radius=1;
}
Circle2d::Circle2d(double a,double b,double c){
x=0;
y=0;
radius=1;
x=a;
y=b;
radius=c;
}
double Circle2d::getPerimeter(){
double PI = 3.14159;
return (2 * PI * radius);
}
double Circle2d::getArea(){
double PI = 3.14159;
return (PI * (radius*radius));
}
bool Circle2d::contains(double a, double b){
int deltaX = a - x;
int deltaY = b - y;
double deltaR = sqrt((float )(deltaX*deltaX)+(deltaY*deltaY));
return deltaR<=radius;
}
bool Circle2d::overlaps(Circle2d &circle)
{
// 'this' points to the object in which calls the function
double c3Radius = circle.getRadius();
double c3X = circle.getX();
double c3Y = circle.getY();
double c1Radius = this ->getRadius();
double c1X = this ->getX();
double c1Y = this ->getY();
/* Circle equation (x - h)^2 + (y - k)^2 = r^2....Basically you just have to find the distance between the two centers.
Now take the two radii and add them up. If they are less than this distance, they won't intersect. */
double Dx = c3X - c1X;
double Dy = c3Y - c1Y;
double c = sqrt( (Dx*Dx + Dy*Dy) ); // distance between two centers
double sumRad = c3Radius + c1Radius;
// Testing for overlap
if (c >= sumRad)
return true ; // true means they intersect
else
{
return false ;
}
}
bool Circle2d::contains(Circle2d &circle){
double c3Radius = circle.getRadius();
double c3X = circle.getX();
double c3Y = circle.getY();
double c1Radius = this ->getRadius();
double c1X = this ->getX();
double c1Y = this ->getY();
if (c1Radius > c3Radius)
{
double Dx = c3X - c1X;
double Dy = c3Y - c1Y;
double c = sqrt( (Dx*Dx + Dy*Dy) );
double diffRad = c1Radius - c3Radius;
if (c > diffRad)
return true ; // true means it contains
else
{
return false ;
}
}
else
{
double Dx = c3X - c1X;
double Dy = c3Y - c1Y;
double c = sqrt( (Dx*Dx + Dy*Dy) );
double diffRad = c3Radius - c1Radius;
if (c > diffRad)
return true ; // true means it contains
else
{
return false ;
}
}
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
#ifndef CIRCLE2D_H
#define CIRCLE2D_H
class Circle2d
{
public :
double getCenter();
double getX();
double getY();
double getRadius();
Circle2d();
Circle2d(double a,double b,double c);
double getArea();
double getPerimeter();
bool contains(double x, double y);
bool contains(Circle2d &circle);
bool overlaps(Circle2d &circle);
private :
double x;
double y;
double radius;
}
#endif
Nov 30, 2011 at 9:34pm UTC
No semicolon after definition of Circle2d.
Nov 30, 2011 at 9:36pm UTC
do you mean where i said #define CIRCLE2D ?
Nov 30, 2011 at 9:39pm UTC
No. I mean the class Circle2d.
Last edited on Nov 30, 2011 at 9:39pm UTC
Nov 30, 2011 at 9:46pm UTC
oh dang didn't even notice that thank you =)
now it is giving me a link error though :/
Last edited on Nov 30, 2011 at 9:46pm UTC
Nov 30, 2011 at 9:50pm UTC
None of these are defined:
1 2 3 4 5
//class Circle2d
double getCenter();
double getX();
double getY();
double getRadius();
Nov 30, 2011 at 9:50pm UTC
nvm i know whats wrong
Topic archived. No new replies allowed.