opAssign and classes
Bill Baxter
dnewsgroup at billbaxter.com
Sun Dec 24 18:26:32 PST 2006
I wrote a class with an opAssign.
But I find I keep getting bitten by this:
MyType x = value;
When I should be typing:
MyType x = new MyType;
x = value;
Somehow I just keep forgetting to do that.
Then I get a nice nondescript "Error: Access violation" at some unknown
point in my program that I have to track down.
Anyone else find themselves making this kind of error?
Any thoughts for how I or the compiler could help protect against this
kind of mistake?
I thought I could stick a check for 'this is null' in the opAssign
method but that doesn't help because apparently it's dereferencing the
null pointer to look up opAssign's address that causes the Error, not
what happens in the call itself.
--bb
More information about the Digitalmars-d
mailing list