Witam.
Napisałem funkcje która sprawdza czy plik istnieje i drugą która oblicza liczbę wierszy w pliku.
void shortroute::read_file(){
string filename;//filename
ifstream file; //input file
cout<<"Please enter name of file which store data.\n";
getline (cin,filename);
file.open(filename.c_str());
if(file.good()){
lines=0;
count();
}else{
cout<<"Enter correct filename!\n";
}
}
void shortroute::count(){
string line;
while( getline(file, line)){
lines++;
}
}
Dostaję błąd file undeclared identifier.
Jak zrobić żeby funkcja count 'widziała' zmienna file która jest zadeklarowana w f read_file()?