General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old November 9th, 2003, 12:48 AM
Meindert Meindert is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 5 Meindert User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Unhappy Run-time error...plaese help me have a look my code!

I got the run-time error but i dont know how to solve it...please help me, Thanks!

http://us.f1.yahoofs.com/users/3fad...cYzdr_A_JA.Z6pC

//This is my driver class which used to run my program
Code:
#include <iostream.h>
#include "Draw.h"

void main() {
	Position p[3];
	p[0] = Position (0.0f, 1.0f, -6.0f);
	p[1] = Position (-1.0f, -1.0f, -6.0f);
	p[2] = Position (1.0f, -1.0f, -6.0f);
	Triangle* myTriangle = new Triangle(p);
	Draw *draw = NULL;
	draw->addTriangle(myTriangle);	// call addTriangle function to add a triangle
	draw->DrawTriangle(myTriangle);
}


//Header File - Draw.h
Code:
#include "Triangle.h"

class Draw
{
	Triangle *T;
	Triangle *triangle[50];	// array contains pointers to Triangles
	Position *pos;
public:
	void addTriangle(Triangle *T);
	void DrawTriangle(Triangle *T);
};


//Draw.cpp which will add and draw the Triangle
Code:
#include "Draw.h"

int i=0;
//This function will accept a parameter, pointer to Triangle and places it inside the 
//array defined above. (Do i need to enlarge the array if i need to add more?)
void Draw::addTriangle(Triangle *T) {
	triangle[i] = T;	// <-- run-time error here
	i++;
}
void Draw:: DrawTriangle(Triangle *T) {
	for(int j=0; j<i; j++) {
		pos = triangle[j]->getVertices();
	}
}


//Header File - Triangle.h
Code:
#include "Position.h"

class Triangle
{
	Position position[3];
	float red;
	float green;
	float blue;
public:
	Triangle(Position position[]);
	void setColor(float red, float green, float blue);
	float getRed();
	float getGreen();
	float getBlue();
	Position* getVertices();
};


//This is Triangle.cpp file
Code:
#include "Triangle.h"

Triangle::Triangle(Position position[]):red(1.0), green(1.0), blue(1.0) {
	this->position[0] = position[0];
	this->position[1] = position[1];
	this->position[2] = position[2];
}
void Triangle::setColor(float red, float green, float blue) {
	this->red = red;
	this->green = green;
	this->blue = blue;
}
float Triangle::getRed() {
	return red;
}
float Triangle::getGreen() {
	return green;
}
float Triangle::getBlue() {
	return blue;
}
Position* Triangle::getVertices() {
	return position;
}


//Header File - Position.h
Code:
class Position
{
	float x;
	float y;
	float z;
public:
	Position();
	Position(float x, float y, float z);
	float getX();
	float getY();
	float getZ();
};


//This is Position.cpp file
Code:
#include "Position.h"

Position::Position() { }
Position::Position(float x, float y, float z) {
	this->x = x;
	this->y = y;
	this->z = z;
}
float Position::getX() {
	return x;
}
float Position::getY() {
	return y;
}
float Position::getZ() {
	return z;
}


Thanks for viewing...

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > Run-time error...plaese help me have a look my code!


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway