C/C++ Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingC/C++ 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 May 4th, 2006, 05:19 PM
danlk2 danlk2 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2006
Posts: 7 danlk2 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 43 m 26 sec
Reputation Power: 0
Weird compilor error, need help for assignment

I'm doing an assignment right now regarding headers and overloaded operators and classes and everything, this is my triangle.cpp file defining all my equations or whatever, I get this error and idk what i did wrong
(i can post the whole thing if needed)


cd ~/
g++ Triangle.cpp
Undefined first referenced
symbol in file
main /usr/local/lib/gcc-lib/sparc-sun-solaris2.7/2.95.2/crt1.o
ld: fatal: Symbol referencing errors. No output written to a.out
collect2: ld returned 1 exit status

Compilation exited abnormally with code 1 at Thu May 4 17:15:22

Reply With Quote
  #2  
Old May 4th, 2006, 05:22 PM
danlk2 danlk2 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2006
Posts: 7 danlk2 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 43 m 26 sec
Reputation Power: 0
//

// Triangle.cpp

//

// Implementation for the Triangle ADT

//



#include <iostream>

#include <cmath>

using namespace std;


#include "Triangle.h"



//////////////////////////////////////////////////////

// Triangle() //
// Triangle.cpp
//
// Implementation for the Triangle ADT
//
// default constructor
Triangle::Triangle() : s1(3), s2(4), s3(5)
{

}


//////////////////////////////////////////////////////

// Triangle(int a, int b, int c)

//////////////////////////////////////////////////////
// Triangle() )
// explicit contructor


Triangle::Triangle(int a, int b, int c) : s1(a), s2(b), s3(c)

{

if (!isValid())
{

cout << "INVALID TRIANGLE! Resetting to <3,4,5>\n";

s1 = 3;

s2 = 4;

s3 = 5;

}

}



//////////////////////////////////////////////////////
// Triangle:erimeter()

//

// The perimeter is the sum of the sides of the triangle. This value

// is returned.

//

int Triangle:erimeter()

{

return (s1 + s2 + s3);

}
//Find the area of the triangle

double Triangle::area ()
{
double s= (s1+s2+s3)/2;
return sqrt(s*(s-s1)*(s-s2)*(s-s3));
}

istream& operator>>(istream& in, Triangle& t)
{

cin >> t.s1 >> t.s2 >> t.s3;

return in;

}

ostream& operator<<(ostream& out, Triangle& t)
{
out<<"<"<<t.s1<<","<<t.s2<<","<<t.s3<<">";

return out;
}


bool Triangle::isValid()
{
if (
s1 < 0 ||
s2 < 0 ||
s3 < 0 ||
s1 + s2 <= s3 ||
s1 + s3 <= s2 ||
s2 + s3 <= s1)
return false;
else
return true;
}

bool Triangle::isRight()
{
if (
(s1*s1)+(s2*s2)==(s3*s3) ||
(s1*s1)+(s3*s3)==(s2*s2) ||
(s3*s3)+(s2*s2)==(s1*s1)
)
return true;
else
return false;
}

bool operator>(Triangle& t1, Triangle& t2)
{
if(
t1.area()>t2.area())
return true;
else
return false;
}

bool operator==(Triangle& t1, Triangle& t2)
{
if(
t1.area()==t2.area())
return true;
else
return false;
}









I NEED HELP!!!! I NEED A GOOD GRADE ON THIS ASSIGNMENT!!! just help me out with my error, thanks a ton

Reply With Quote
  #3  
Old May 4th, 2006, 08:28 PM
danlk2 danlk2 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2006
Posts: 7 danlk2 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 43 m 26 sec
Reputation Power: 0
no suggestions from anyone?!?!?!

Reply With Quote
  #4  
Old May 4th, 2006, 11:18 PM
ubergeek ubergeek is offline
Contributing User
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jan 2005
Posts: 600 ubergeek User rank is Private First Class (20 - 50 Reputation Level)ubergeek User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 2 Days 22 h 40 m 27 sec
Reputation Power: 4
Send a message via AIM to ubergeek
perhaps it would help if you post Triangle.h
also, put your code between
Code:
 and 
tags to preserve formatting

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingC/C++ Help > Weird compilor error, need help for assignment


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 3 hosted by Hostway
Stay green...Green IT