I am getting an error I do not know how to fix
Here is my code
#include<iostream>
#include<vector>
#include<fstream>
#include<cstdlib>
#include<string>
#include"account.h"
using std::cout;
using std::string;
using std::fstream;
using std::ifstream;
using std::vector;
class application{
private:
ifstream accountRead("account.dat");
if(!accountRead){
cerr << "Cannot locate file needed to be opened";
exit(1);
}
vector<accountSetup> a;
public:
int main(){
cout<<"Hooray!";
return 0;
}
};
here is the error:
1>c:\users\chris\documents\visual studio 2008\projects\assignment 5\assignment 5\application.h(17) : error C2059: syntax error : 'string'
1>c:\users\chris\documents\visual studio 2008\projects\assignment 5\assignment 5\application.h(19) : error C2059: syntax error : 'if'
1>c:\users\chris\documents\visual studio 2008\projects\assignment 5\assignment 5\application.h(19) : error C2334: unexpected token(s) preceding '{'; skipping apparent function body
actually I wrote it this way because my teacher wants us to have an application class. This is not the main class here are all three pages of my code: [b]application.h[/b]
#include<fstream>
#include<iostream>
#include<string>
#include<cstdlib>
#include<vector>
#include"account.h"
using std::cout;
using std::string;
using std::fstream;
using std::ifstream;
using std::vector;
class application{
private:
ifstream accountRead("account.dat");
vector<accountSetup> a;
public:
int main(){
cout<<"Hooray!";
return 0;
}
}; [b]main.cpp[/b]
#include"application.h"
#include<iostream>
using namespace std;
int main(){
application app;
return app.main();
} account.h
#include<iostream>
#include<string>
using std::string;