On Apr 26, 1:31 am, Ron Eggler <unkn...@example.com> wrote:
> the problem actually was that who ever started writing this
> code (I'm just here to get it working
) declared ofs as an
> ofstream pointer. That's why ->, I just removed the pointer
> and replaced all -> with .and it works just fine. So
> fstream:
pen() doesn't work with an empty pointer, it
> actually needs a valid fstream handle to load the file handle
> in there - right?
Obviously. A member function can only be called on an object.
Defining a pointer doesn't create an object of the pointed to
type; all it creates is a pointer, initialized (or not) as you
specified.
The recommendation to pull out the debugger was not a good one.
You don't use a debugger unless you know exactly what you're
looking for, which means some understanding of the code already.
Using a debugger here would only have been valid if you knew (or
at least thought you knew) where the object was allocated and
the pointer initialized; you would note the address returned
from the new expression, and then verify that you still had the
same address in the pointer here. Using a debugger without
knowing exactly what you are looking for is a very bad reaction.
--
James Kanze (GABI Software) email:
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34