void Shape::D_square()
{
for(i=0;i<height;i++)
{
for(j=0;j<height;j++)
{
cout<<f_char<<" ";
}
cout<<"\n";
}
}
void Shape::D_rectangle()
{
for(i=0;i<height;i++)
{
for(j=0;j<(2*height);j++)
{
cout<<f_char<<" ";
}
cout<<"\n";
}
}
for example i have a class and two public member function which is D_square() and D_rectangle()
Is it possible to save those output from function to binary file?
or i need to add extra code like this.....
public:
save(ofstream& out); // saves member data one at a time
load(ifstream& in); // loads member data one at a time
... // other class definition stuff
};
// The save and load methods do things member by member. I do this
// instead of saving the whole object to avoid issues with virtual
// functions.
Shape::save(ofstream& out);
{
out.write(static_cast<char*>&memberVar1, sizeof(memberVar1));
// etc.
}
Shape myObject;
...
myObject.save(ofs);
or i need to save one by one using for loop?
This post has been edited by poplol: 28 November 2009 - 06:49 PM

New Topic/Question
This topic is locked




MultiQuote


|