Use of undeclared identifier

Hello, I am getting the error "Use of undeclared identifier." I am sure that I have declared them, but apparently not in a proper manner. Still, I can't find what I'm doing wrong. Is it something with my class? I'm new to OOP.

I've seen some similar problems on the web, but none that really apply to, or have helped in this particular program.

The program is going to read a file with stock prices and output 2 listings by stock symbol and by stock gain high to low.

This code is a header file. It's where I'm getting the most errors. I have another header file and a ccp file that have some errors, but not as many as this one. I can post those too if it will help out. Thanks in advance for any help.

Errors on lines 111-117, 120, 122, 125, 128, 133, 136, & 142

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
210
  /*
#ifndef STOCKTYPE_H
#define STOCKTYPE_H
#include <iostream>
using namespace std;

class stockType
{
public:
    ifstream & operator>>(ifstream & infile);
    ostream & operator<<(ostream & os);
    stockType();
    ~stockType();
    char * symbol;
    double openingPrice;
    double closingPrice;
    double todayHigh;
    double todayLow;
    double prevClose;
    int volume;
    float percent_calc();

private:
    enum{BUFFER = 20};
};

#endif
 
 */

//file name: stockType.h //NEW ONE
#ifndef H_stockType
#define H_stockType

#include <iostream>
#include <fstream>
#include <cstring>
#include "stock.h"

using namespace std;

class stockType
{
    friend ostream& operator<< (ostream&, const stockType&);
    friend ifstream& operator>> (ifstream&, stockType&);
    
public:
    void setStockInfo(Stock symbol, double openPrice,
                      double closeProce, double high,
                      double Low, double prevClose,
                      int shares);
    
    Stock getSymbol();
    double getPercentChange();
    double getOpenPrice();
    double getClosePrice();
    double getHighPrice();
    double getLowPrice();
    double getPrevPrice();
    int getNoOfShares();
    
    stockType();
    stockType(Stock symbol, double openPrice,
              double closeProce, double high,
              double Low, double prevClose,
              int shares);
    
    int operator ==(stockType other);
    int operator !=(stockType other);
    int operator <=(stockType other);
    int operator >=(stockType other);
    int operator >(stockType other);
    int operator <(stockType other);
    
private:
    Stock stockSymbol;
    double todayOpenPrice;
    double todayClosePrice;
    double todayHigh;
    double todayLow;
    double yesterdayClose;
    double percentChange;
    int noOfShares;
};

//default constructor
stockType::stockType(){
	//stockSymbol = "***";
	todayOpenPrice = 0.00;
	todayClosePrice = 0.00;
	todayHigh = 0.00;
	todayLow = 0.00;
	yesterdayClose = 0.00;
	noOfShares = 0;
}

//constructor
stockType::stockType(Stock symbol, double openPrice,
                     double closeProce, double high,
                     double Low, double prevClose,
                     int shares){
    setStockInfo(symbol, openPrice, closeProce,
                 high, Low, prevClose, shares);
}
//set the information for each stock
void setStockInfo(Stock symbol, double openPrice,
                  double closeProce, double high,
                  double Low, double prevClose,
                  int shares){
    
	stockSymbol = symbol;
	todayOpenPrice = openPrice;
	todayClosePrice = closeProce;
	todayHigh = high;
	todayLow = Low;
	yesterdayClose = prevClose;
	noOfShares = shares;
}

newString getSymbol(){
    
	return stockSymbol;
}

double getPercentChange(){
    
	percentChange = ((todayClosePrice - yesterdayClose) / yesterdayClose) * 100;
	return percentChange;
}

double getOpenPrice(){
    
	return todayOpenPrice;
}

double getClosePrice(){
    
	return todayClosePrice;
}
double getHighPrice(){
    
	return todayHigh;
}

double getLowPrice(){
    
	return todayLow;
}

double getPrevPrice(){
    
	return yesterdayClose;
}

int getNoOfShares(){
    
	return noOfShares;
}

//Overload the relational operators.
bool stockType::operator==(const Stock& rightStr) const{
    
	return (strcmp(sortIndicesGainLoss, rightStr.sortIndicesGainLoss) == 0);
}

bool stockType::operator<(const Stock& rightStr) const{
    
	return (strcmp(sortIndicesGainLoss, rightStr.sortIndicesGainLoss) < 0);
}

bool stockType::operator<=(const Stock& rightStr) const{
    
	return (strcmp(sortIndicesGainLoss, rightStr.sortIndicesGainLoss) <= 0);
}

bool stockType::operator>(const Stock& rightStr) const{
    
	return (strcmp(sortIndicesGainLoss, rightStr.sortIndicesGainLoss) > 0);
}

bool stockType::operator>=(const Stock& rightStr) const{
    
	return (strcmp(sortIndicesGainLoss, rightStr.sortIndicesGainLoss) >= 0);
}

bool stockType::operator!=(const Stock& rightStr) const{
    
	return (strcmp(sortIndicesGainLoss, rightStr.sortIndicesGainLoss) != 0);
}

//Overload the stream insertion operator <<
ostream& operator<< (ostream& osObject, const stockType& stock){
    
	osObject << stock.sortIndicesGainLoss;
    
	return osObject;
}

//Overload the stream extraction operator >>
ifstream& operator>> (ifstream& isObject, stockType& stock){
    
	char temp[81];
    
	isObject >> setw(81) >> temp;
	str = temp;
	return isObject;
}

#endif


If history is anything to go by it's probably something really silly that I haven't thought about, but I have been struggling with this for 3 days now and am at my whits end. Cheers. If I can get this to compile then I can figure out if I'm on the right track or not.
Last edited on
You're missing stockType:: in front of most of your functions, if the function is declared in stockType then the definition should have stockType::
Got it. Thanks. Yep, that cleared up a lot of the issues that I was having. Cheers.
Topic archived. No new replies allowed.