Click here to Skip to main content
14,878,718 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I get this error although i haven t used any classes in my code. i think that my problem is there but don t know exactly what it is
void openFile(ifstream infile,int **matrix,int y,int x){...
mstrix[y][x]=atoi(a_string.cstr())...
Posted
Comments
Richard MacCutchan 19-Nov-14 13:03pm
   
Where do you get this error, please provide the actual line of code and the exact message.

you have used classes: a_string.cstr().

Comment all code out til you find the place. Your compiler hould yell on which line it is complaining....

Somebody else had similar problems,
   
Comments
Aescleal 20-Nov-14 7:49am
   
+5ed to compensate for whoever hit you with a 1. I don't mind univoters if they tell you why...
If it's whinging about the copy constructor of ios or iosbase being inaccessible it's the copying of an ifstream that's causing the problem. Try passing the stream by reference, or, for the sake of sanity in debugging and testing, pass it as a reference to an istream.

If that lot sounds like Esperanto then grab a textbook and lookup references, copy construction and the iostream classes in the standard library.
   
Comments
Aescleal 20-Nov-14 7:49am
   
So Mr. Downvoter - what's wrong with the answer I've given here? If it was factually incorrect (i.e. it's not the copying of ifstream that's causing the problem) I'd like to know what's wrong so I don't make the same sort of mistakes in my code as the poster. If the advice I've given the poster is incorrect (get some understanding of how and why you can't copy construct an ifstream and why you have to use a reference) I'd also like to know so I give better advice in the future.

Likewise I'm sure Karsten would like some fuller explanation as to what's wrong with his answer.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900