Difficulty with Building a Triangle in C++ (First "Real" Program)

Hey,

I need some help building a triangle in c++. I feel like I'm screwing up real bad so I apologize upfront if this program is hideous. Please take a look and let me know what you think.

When I try to execute program my computer just gives me an "illegal instruction" error


// File: stars.cxx 01/20/2011
// The main purpose of this program is to draw triangles in C++ for HW #1

//Directives:
#include <graphics.h>
#include <cstdlib>
#include <cmath>
using namespace std;

//----------------------------------------------------------------------------
const int S = 800;
//----------------------------------------------------------------------------

//----------------------------------------------------------------------------
//Prototypes
void draw_traingle(double x, double y, double angle);
//----------------------------------------------------------------------------

//----------------------------------------------------------------------------
int main()
{
initwindow (S,S, "Stars Homework #1");
draw_traingle(50, 50, 2*M_PI/3);
delay(2000);
return EXIT_SUCCESS;

}

//----------------------------------------------------------------------------
void cent_x(double x)
{
//Defining center
cent_x(int(x));
}

//----------------------------------------------------------------------------

//----------------------------------------------------------------------------
void cent_y(double y)
{
//Defining center
cent_y(int(y));
}
//----------------------------------------------------------------------------

//----------------------------------------------------------------------------
void peak_angle(double angle)
{
//Defining vertex angle
peak_angle(int(angle));
}
//----------------------------------------------------------------------------

//----------------------------------------------------------------------------
void radius(double x, double y)
{
radius(int(cent_y), int(cent_y));

}
//----------------------------------------------------------------------------
void draw_triangle(double x, double y, double angle)
{
//draw the triangle
draw_triangle(int(cent_x + radius*cos(peak_angle)), int(cent_y + radius*sin(peak_angle)), int(angle));
}
//----------------------------------------------------------------------------


After Compiled:
bgi++ -Wall -g stars.cxx -o stars
stars.cxx: In function `void draw_triangle(double, double, double)':
stars.cxx:65: error: no matching function for call to `cos(void (&)(double))'
C:/Program Files/Colorado/cs1300/include/math.h:134: error: candidates are:
double cos(double)
C:/Program Files/Colorado/cs1300/include/c++/3.3.1/cmath:282: error:
long double std::cos(long double)
C:/Program Files/Colorado/cs1300/include/c++/3.3.1/cmath:278: error:
float std::cos(float)
stars.cxx:65: error: no matching function for call to `sin(void (&)(double))'
C:/Program Files/Colorado/cs1300/include/math.h:133: error: candidates are:
double sin(double)
C:/Program Files/Colorado/cs1300/include/c++/3.3.1/cmath:522: error:
long double std::sin(long double)
C:/Program Files/Colorado/cs1300/include/c++/3.3.1/cmath:518: error:
float std::sin(float)

Compilation exited abnormally with code 1 at Sat Jan 22 21:11:40

Thanks - I really appreciate the help




Last edited on
bump
Topic archived. No new replies allowed.