Compliler Error

Ok What does the compiler error mean when it says

multiple definition of `Resistance::Resistance(double, double, std::string*, std::string, double)'
first defined here
multiple definition of `Resistance::string_Convert()'
first defined here
multiple definition of `Resistance::ResistToleranceConvert()'
first defined here
multiple definition of `Resistance::Rmax()'
first defined here
multiple definition of `Resistance::Rmin()'
first defined here
multiple definition of `Resistance::Set_Units()'
first defined here
[Build Error] ["Programming] Error 1

my Class is here
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
#include <string>
#include<iostream>
#include<cmath>

using namespace std;
const int X = 4;
class Resistance
{
friend void ConvertColor(char, string[], int);
private:
double ResistValue;
double Tolerance;
double ConFact;
string Band[X];
string Units;
public:
Resistance(double, double, string [], string, double); 
int string_Convert();
int ResistToleranceConvert(); 
double Rmax();
double Rmin();
double Standard_Resistance();
void Set_Units();
void Display(double, double);
void Display_Color();
};


Here is my functions page

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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
#include <string>
#include<iostream>
#include<cmath>
#include "Class.h"
#include <sstream>

using namespace std;
string Lowercase(string);
Resistance::Resistance(double R, double T, string Color[X], string U, double C)
{
ResistValue = R;
Tolerance = T;
for (int i = 0; i < X; i++)
{
Band[i] = Color[i];
}
Units = U;
ConFact = C;
}
//***STRING*CONVERSION****************…
int Resistance::string_Convert()
{
double ResistArray[X];
int i;

for (i = 0; i < X; i++)
Band[i] = Lowercase(Band[i]);

if (Band[0] == "black" || Band[0] == "gold" || Band[0] == "silver")
return 1;

if (Band[1] == "gold" || Band[0] == "silver")
return 2;

for (i = 0; i < X - 1; i++)
{
if (Band[i] == "black")
ResistArray[i] = 0;
else if (Band[i] == "brown")
ResistArray[i] = 1;
else if (Band[i] == "red")
ResistArray[i] = 2;
else if (Band[i] == "orange")
ResistArray[i] = 3;
else if (Band[i] == "yellow")
ResistArray[i] = 4;
else if (Band[i] == "green")
ResistArray[i] = 5;
else if (Band[i] == "blue")
ResistArray[i] = 6;
else if (Band[i] == "violet")
ResistArray[i] = 7;
else if (Band[i] == "gray")
ResistArray[i] = 8;
else if (Band[i] == "white")
ResistArray[i] = 9;
else if (Band[i] == "silver")
ResistArray[i] = -1;
else if (Band[i] == "gold")
ResistArray[i] = -2;
else
return 5;
}

if (Band[3] == "gold")
Tolerance = 5.0;
else if (Band[3] == "silver")
Tolerance = 10.0;
else if (Band[3] == "none")
Tolerance = 20.0;
else
return 4;

ResistValue = (ResistArray[0]*10+ResistArray[1])*pow(1…

return 0;
}

//***RESISTOR*TOLERANCE*CONVERSION****…
int Resistance::ResistToleranceConvert()
{

string ResistString;
int i(0), C(0), element(0);

ostringstream os;
os << ResistValue;
ResistString = os.str();

while(i < ResistString.length() && element < 3)
{
if (isdigit(ResistString.at(i)))
{ 
ConvertColor(ResistString.at(i), Band, element);
element++;
}
else if (ResistString.at(i) == '^')
{
if (ResistString.at(i+1) == '-')
{
C = '-' + ResistString.at(i+2);
ConvertColor(C, Band, element);
element++;
}
else
{
C = ResistString.at(i+1);
ConvertColor(C, Band, element);
element++;
}
} 
i++;
}

if (ResistValue < 0.01 || ResistValue > 100000000)
return 1;

if (Tolerance == 5)
Band[3] = "Gold";
else if (Tolerance == 10)
Band[3] = "Silver";
else if (Tolerance == 20)
Band[3] = "None";
else
return 2;

return 0;
//***MAX/MIN*******************************************************************
double Resistance::Rmax()
{
    return(ResistValue * (1.0 + Tolerance/100.));
}
double Resistance::Rmin()
{
    return(ResistValue * (1.0 - Tolerance/100.));
}
//***CONVERSION*TO*COLOR*******************************************************
void ConvertColor(char RValue, string Band[4], int element)
{
     int Resist;
     
     Resist = int(RValue);
     
     if (Resist == 0)
         Band[element] = "black";
     else if (Resist == 1)
         Band[element] = "brown";
     else if (Resist == 2)
         Band[element] = "red";
     else if (Resist == 3)
         Band[element] = "orange";
     else if (Resist == 4)
         Band[element] = "yellow";
     else if (Resist == 5)
         Band[element] = "green";
     else if (Resist == 6)
         Band[element] = "blue";
     else if (Resist == 7)
         Band[element] = "violet";
     else if (Resist == 8)
         Band[element] = "gray";
     else if (Resist == 9)
         Band[element] = "white";
     else if (Resist == -1)
         Band[element] = "silver";
     else 
         Band[element] = "gold";
         
     return;
} 
//***SET*UNITS*****************************************************************
void Resistance::Set_Units()
{
     if (ResistValue < 990)
        {
            Units = " ohms";
            ConFact = 1.0;
        }
     else if (ResistValue >= 1000 && ResistValue <= 999000)
        {
            Units = " kilaohms";   
            ConFact = 1.0/1000.0;
        }
     else
        { 
            Units = " Megaohms";
            ConFact = 1.0/1000000.0;
        }
     return;
}          
//***DISPLAY*COLOR*************************************************************
void Resistance::Display_Color()
{
     cout << "The corresponding color bands are:\n";
     for (int i = 0; i < X; i++)
     {
         cout << Band[i] << endl;
     }
     return;
}     
//***TO*LOWERCASE**************************************************************
string Lowercase(string Band)
{
    for (int j = 0; j < int(Band.length()); j++)
        {
            Band[j] = tolower(Band[j]);
        }
    return Band;
}


Here is the main code
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
#include <string>
#include <iostream>
#include <cmath>
#include "Implement.cpp"
#include <sstream>

int main()
{
    
    string Array[X];
    string Units = " ohms";
    double ConFact = 1.0;
    double R, T, Min, Max;
    int i, Error_Code, Number;
    char Option;
    
  do
    {
         
    system("cls");
    
    cout << "Do you want to input the band colors or the resistance and "
         << "tolerance?\n"
         << "Please enter 1 for Band Colors \n"
         << "Please enter 2 for Resistance and Tolerance \n";
    cin >> Number;
    cout << endl;
    
  if (Number == 1)
  {
    cin.ignore();  
    for (i = 0; i < X ; i++)
    {
        cout << "Please enter the color bands of your resistor. " << endl;
        getline(cin, Array[i]);
    }
    
    Resistance Resistor(R, T, Array, Units, ConFact);
               
    Error_Code = Resistor.string_Convert();
    if (Error_Code == 1)
        cout << "Invalid color band entered in band A.\n";
    else if (Error_Code == 2)
        cout << "Invalid color band entered in band B.\n";
    else if (Error_Code == 4)
        cout << "Invalid color band entered in band D.\n";
    else if (Error_Code == 5)
        cout << "Misspelled or invalid color.\n";
    else
    {
        Max = Resistor.Rmax();
        Min = Resistor.Rmin();                   
        
        Resistor.Set_Units();
                                  
        Resistor.Display(Min, Max);
    }
  }
  
  else if (Number == 2)
  {
    cout << "Enter a resistance value: ";
    cin >> R;
    cout << "Enter a tolerance value: ";
    cin >> T;
    
    Resistance Resistor(R,T,Array, Units, ConFact);
    
    Error_Code = Resistor.ResistToleranceConvert();
    if (Error_Code == 1)
        cout << "Invalid resistance entered.\n";
    else if (Error_Code == 2)
        cout << "Invalid tolerance entered.\n";
    else
       Resistor.Display_Color();
  }
  else
  {
    cout << "Invalid option entered.\n\n";
  }
    cout << "\nWould you like to run the program again?\n"
         << "Please enter Yes (Y) or No (N).\n\n";
         cin >> Option;
    cin.ignore(); 
  }
  while(tolower(Option) == 'y' || Number > 2 || Number < 1);
    
  system("pause");
  return 0;
}
Last edited on
I think this might be because you're including Implement.cpp. Are you compiling this in an IDE (visual studio or the like)? if so it is probably set to compile each .cpp file separately. Try not including "Implement.cpp" in your main file
You should actually check out this awesome article: http://cplusplus.com/forum/articles/10627/ if you want to learn more about the difference between header and source files and how to keep everything organized in a project with multiple source files
tyvm sliced, that worked perfectly.
Topic archived. No new replies allowed.