[gameprogrammer] Re: weird problem passing ofstream as parameter

  • From: Husam Zakaria <hzcppff@xxxxxxxxx>
  • To: gameprogrammer@xxxxxxxxxxxxx
  • Date: Sat, 20 Feb 2010 23:55:59 +0300

LOL :D

sorry but this is what happened when you learn C# before you learn C++

you don't have to pass the ofstream by value, you have to pass it by
reference like this

class EntityManager {
public:
saveEntities(ofstream& savefile);
}

or you can pass a pointer to ofstream object like this

class EntityManager {
public:
saveEntities(ofstream* savefile);
}

but the first way is more C++ likely
___________________
with best regards
Husam Zakaria



On 2/17/10, Brian Barrett <brian.ripoff@xxxxxxxxx> wrote:
> Hi.
>
> What have you tried? http://whathaveyoutried.com
>
> I'll give you a hint: what does it mean to create a copy of a file stream?
>
> On 17 February 2010 09:02, Roger Durañona Vargas <luo_hei@xxxxxxxx> wrote:
>> Can somebody explain me if there is some special requirement to pass a
>> file as parameter?
>> I have this:
>> class EntityManager {
>> public:
>> saveEntities(ofstream savefile);
>> }
>>
>>
>> But this produces a lot of errors with gcc, saying that something is
>> private. any idea?
>>
>
> ---------------------
> To unsubscribe go to http://gameprogrammer.com/mailinglist.html
>
>
>

---------------------
To unsubscribe go to http://gameprogrammer.com/mailinglist.html


Other related posts: