Can't figure out where I'm going wrong here.

I am getting [Linker error] undefined reference to `printResults(std::ostream&, double, double, double, double, double)'

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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#include <iostream>
#include <fstream>
#include <cmath>

using namespace std;

ofstream fout;
ifstream fin;

void printIdInfo(ostream &);
void readData(double &, double &, double &);
void printInvalidMsg();
void printEquilateralMsg();
double areaEquilateral(double);
double perimeterTriangle(double, double, double);
double areaTriangle (double side1, double side2, double side3);
void printResults( ostream & , double, double, double, double, double);


int main()
{
    
    double side1,
           side2,
           side3,
           equTriArea,
           tri_area,
           tri_perim;
       
    
    
    fin.open("prog5_inp5.txt");
    fout.open("prog5_out5.txt");
     
    do
    {
             printIdInfo(cout);
    
             printIdInfo(fout);
    
             readData(side1, side2, side3);
    
             if ( side1 <= 0 || side2 <= 0 || side3 <= 0)
             printInvalidMsg();
    
             else 
             {
                  if ( side1 == side2 && side1 == side3 )
                  {
                     printEquilateralMsg();
                     tri_area= areaEquilateral(side1);
                     tri_perim= perimeterTriangle(side1, side2, side3);
                     printResults(fout, side1, side2, side3, tri_area,
                     tri_perim);
                  }
    
                  else 
                  {
                     tri_area= areaTriangle (side1, side2, side3);
                     tri_perim= perimeterTriangle(side1, side2, side3);
                     printResults(fout, side1, side2, side3, tri_area, 
                                  tri_perim);
                  }
             }
    }
    while ( side1 <= 0 || side2 <= 0 || side3 <= 0);

    return 0;
    
}
        
void printIdInfo(ostream &out)
{
     out << "Jacob Hummer, Matthew Grant" << endl 
         << "C.S. 1428.0005" << endl
         << "11/12/09" << endl;
}
        
void readData(double &side1, double &side2, double &side3)
{
       fin.open("triangle_sides.txt");
       fin >> side1 >> side2 >> side3;
}


void printInvalidMsg ()
{
     cout << "There were no valid input values on the input file.";
}

        
void printEquilateralMsg()
{
     fout <<"The Triangle is Equilateral " <<endl;
}

        
double areaEquilateral( double side1 )
{
       return ( pow(side1,2) * sqrt(3)) / 4.0;
}

    
double perimeterTriangle(double side1, double side2, double side3)
{
       return side1+side2+side3;
}


double areaTriangle (double side1, double side2, double side3)
{
   double s;
   
   s = perimeterTriangle ( side1, side2, side3 ) / 2.0; 
     
   return sqrt ( s * ( s - side1 ) * ( s - side2 ) * ( s - side3 ) );

void  printResults (double side1, double side2, double side3, double area, 
                   double tri_perim, ostream &out)
{
     printIdInfo(fout);
     fout <<endl
          <<"The sides of the triangle are " <<side1 <<", " <<side2 
          <<", and " <<side3 <<"." <<endl
          <<"The area of the triangle is " <<area <<". \n" 
          <<"The perimeter of the triangle is " << tri_perim 
          << endl << endl;
}

void printResults( ostream & , double, double, double, double, double); is not the same as your definition:

1
2
void  printResults (double side1, double side2, double side3, double area, 
                   double tri_perim, ostream &out)
Got it figured out. Thanks.
Topic archived. No new replies allowed.