Expand|Select|Wrap|Line Numbers
- #include <iostream>
- #include <fstream>
- #include <string>
- using namespace std;
- class stock {
- private:
- string symbol;
- int numshare;
- float price;
- public:
- stock(string symbol1, int numshare1, float price1);
- stock();
- };
The files I am reading in look something like this:
CSCO 100 12.34
MSFT 200 56.78
where the numbers are the symbol, followed by numshare, follewed by price.
This is what I have been trying, and it hasn't been working:
Expand|Select|Wrap|Line Numbers
- for(int j = 0; j<namevector.size(); j++){
- otherfiles.open(namevector[j].c_str());
- while(!otherfiles.eof()){
- otherfiles >> symbol >> numshare >> price;
- if (!otherfiles.eof()){
- stockvector.push_back(symbol, numshare, price);
- }
- }
- otherfiles.close();
- otherfiles.clear();
- }
I'm really sorry, I know this probably isn't very clear, but it's the best job of explaining i can do.