List class

My problem is when i try to call the get function i have no idea how to get the data from my file. it says that it cant convert fstream to int. int is my function parameter. so how do i get it to properly get it from the file?
main.h
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
 #include <string>

using namespace std;

class List 
{
    
    public:
    	
		void print();
		//insert();
		void remove(string a, int b, int c);
		//getLength();
		//isEmpty();
    	bool compare(string inmodel, int inprice, int inyear);
		int getYear(); 
		void    setYear(int in); 
		int     getPrice();  
        void    setPrice(int in);  
        string  getModel();  
        void    setModel(string in); 
        List();
        List(int price,int year,string model);
	
	private:
	
		int price;
		int year;
		string model;
	
	
	struct Node
	{
		
		Node* next;
		Node* head;
		Node* ptr;
		
	};
    
};
	
	



list.cpp
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
#include "main.h" 
#include <string>
 
List::List() //default constructor
{ 
    price = 0; 
    model = "";
    year = 0;
} 

void List::print()  
{  
  
}  
  
bool List::compare(string inmodel, int inprice, int inyear) 
{ 
    if(inmodel == model) { 
        if(inprice == price) { 
            if(inyear == year) { 
                return true; 
            } 
        } 
    } 
    return false; 
} 
  
int List::getYear() 
{ 
    return year; 
} 
  
void List::setYear( int in) 
{ 
    
    year = in; 
} 
  
int List::getPrice() 
{ 
    return price; 
} 
  
void List::setPrice(int in) 
{ 
   price=in;
} 
  
string List::getModel() 
{ 
    return model; 
} 
  
void List::setModel(string in) 
{ 
    model = in; 
} 
  
void List::remove(string a, int b, int c) 
{ 
    if(a == model) { 
        if(b == price) { 
            if(c == year) { 
                model = ""; 
                price = 0; 
                year = 0; 
            } 
        } 
    } 
} 


mainprog.cpp
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
#include <iostream>
#include <string>
#include <cmath>
#include <iomanip>
#include "main.h"
#include <fstream>


using namespace std;


int main()
{
    
    char actionNeeded;
    int numcars=0;
	ifstream inData;
	string infileName;
    List mylist;
    int test=0;
	cout << "Enter the input data file name:" << endl;
	
	cin >> infileName;
	
	inData.open(infileName.c_str());
	

	// make it a loop error message so user doesnt have to restart program. Annoying 
	if(!inData)
	{
		cerr << "Can't open: "  << infileName  << ". Program is stopping" << endl;
		return 1;
		
	}
	
	while (inData)
{

	
	inData>>actionNeeded;
	
	if( !inData)
	{
		break;
	}
		

switch(actionNeeded)
{
  case 'A':
    
  //get and set?
 //  mylist.setPrice(test);
 //  mylist.setYear(inData);
     //List.setModel(inData);
    // mylist.getYear();
     cout <<0;
 

    break;
  case 'R':
   // remove cars function call
 
// call to list.h remove function
  
    break;
  
  case 'L': 
	//List cars function call in list.h
  
	
  
  
  break;
  
	case 'P':
	//call to print in list.h
	
		
	break;

}
}
	
	
	return 0;
}
It would be good to see a sample of the file you're reading from, but perhaps your solution is to read the data from the file into a string and then parse your string into pieces and assign those pieces to the correct variables.

I would also suggest dropping a lot more comments in your code, especially if you want other people to try to read through it and help you.
Topic archived. No new replies allowed.