error: expected constructor, destructor, or type conversion

I got this error message:
error: expected constructor, destructor, or type conversion before ‘=’ token
or something very similar for every line from 34-70. I have no idea what's going wrong. Thanks ahead of time for your help

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
  #include <iostream>
  2 #include <fstream>
  3 #include <string>
  4 #include <iomanip>
  5
  6 using namespace std;
  7
  8 int main();
  9
 10     ifstream inFile;
 11     ofstream outFile;
 12     string inFileName;
 13
 14     float odometer1;
 15     float odometer2;
 16     float odometer3;
 17     float odometer4;
 18
 19     float mile1;
 20     float mile2;
 21     float mile3;
 22
 23     float pumped1;
 24     float pumped2;
 25     float pumped3;
 26     float pumped4;
 27
 28     float gal1;
 29     float gal2;
 30     float gal3;
 31
 32
 33
 34     cout << "Please enter a file name: ";
 35     cin >> inFileName;
 36
 37     inFile.open(inFileName.c_str());
 38
 39     inFile >> odometer1;
 40     inFile >> pumped1;
 41     inFile >> odometer2;
 42     inFile >> pumped2;
 43     inFile >> odometer3;
 44     inFile >> pumped3;
 45     inFile >> odometer4;
 46     inFile >> pumped4;
 47
 48     mile1 = odometer2 - odometer1;
 49     mile2 = odometer3 - odometer2;
 50     mile3 = odometer4 - odometer3;
 51
 52     gal1 = mile1 / pumped1;
 53     gal2 = mile2 / pumped2;
 54     gal3 = mile3 / pumped3;
 55
 56     cout << fixed << setw(24) << "Miles per" << endl;
 57     cout << "Miles  Gallons  Gallon";
 58     cout << "-----  -------  ------";
 59     cout << fixed << setw(4) << mile1;
 60     cout << fixed << setw(9) << setprecision(1) << pumped1;
 61     cout << fixed << setw(8) << setprecision(1) << gal1;
 62     cout << fixed << setw(4) << mile2;
 63     cout << fixed << setw(9) << setprecision(1) << pumped2;
 64     cout << fixed << setw(8) << setprecision(1) << gal2;
 65     cout << fixed << setw(4) << mile3;
 66     cout << fixed << setw(9) << setprecision(1) << pumped3;
 67     cout << fixed << setw(8) << setprecision(1) << gal3;
 68
 69     inFile.close();
 70     outFile.close();
 71
 72 return 0;
 73 }

                                                            1,1          
Last edited on
Topic archived. No new replies allowed.