In article <············@wildcard.demon.co.uk> Cyber Surfer <············@wildcard.demon.co.uk> writes:
It could be written as:
class str {
int iCount;
char achData[1];
};
Then you can allocate the extra memory. C++, like C, doesn't stop
you from doing this.
Ok, you *could* do this by overloading operator new - but God help you
if str has virtual functions as the virtual function table pointer
will be in the middle of your achData array.
In article <················@fat-controller.cs.bham.ac.uk>
···@fat-controller.cs.bham.ac.uk "Paul Flinders" writes:
> Ok, you *could* do this by overloading operator new - but God help you
> if str has virtual functions as the virtual function table pointer
> will be in the middle of your achData array.
That's why I only use that technique in C, or a subset of C++. As far
as I'm aware, you can still use malloc/free to allocate C++ objects,
and you don't have to use virtual destructors. You're choices may be
restricted, compared with some other languages, but it's still possible
to do it. I was simply pointing out another way that it might be done.
--
<URL:http://www.demon.co.uk/community/index.html>
<URL:http://www.enrapture.com/cybes/namaste.html>
<URL:ftp://ftp.demon.co.uk/pub/rfc/rfc1738.txt>
"You can never browse enough."