| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
|
#2
|
|||
|
|||
|
//
// 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 |
|
#3
|
|||
|
|||
|
no suggestions from anyone?!?!?!
|
|
#4
|
|||
|
|||
|
perhaps it would help if you post Triangle.h
also, put your code between Code:
and |
![]() |
| Viewing: Dev Articles Community Forums > Programming > C/C++ Help > Weird compilor error, need help for assignment |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|