Reputation: 11
My program is very easy, all the mess happens around the passing of the ofstream pointer as shown below.
Main programm:
int main()
{...
ofstream otf;
otf.open("hex_movie.xyz");
....
write(int (1),oc,nx,ny,otf,ck)
}
And in the write.h, it begins with
int write(int TYPE,int *oc,int nx,int ny,ofstream otf, double ck)
{.... return 0;}
I used Xcode to debug it, and it shows (only on the line of the write fucntion, sorry I cannot upload a screen shot)
Xcode/GGK/GGK/ggk.cpp:110:28: Call to implicitly-deleted copy constructor of 'ofstream' (aka 'basic_ofstream')
Can anybody help me with this, thank you very much! :)
Upvotes: 0
Views: 116
Reputation: 10849
You are currently passing by value otf
try passing it by reference
int write(int TYPE,int *oc,int nx,int ny,ofstream& otf, double ck)
Upvotes: 2
Reputation: 17605
In the signature of the function
int write(int TYPE,int *oc,int nx,int ny,ofstream otf, double ck)
the argument otf
is of type ofstream
, which means call by value; consequently, otf
will be a copy of the agrument of the caller. You could change the signature to
int write(int TYPE,int *oc,int nx,int ny,ofstream& otf, double ck)
which will use call by reference and will use the same object as the caller.
Upvotes: 3