Re: Abstract class variables question
- From: "tshad" <tfs@xxxxxxxxxxxxxx>
- Date: Thu, 15 Nov 2007 18:00:36 -0800
"Ben Voigt [C++ MVP]" <rbv@xxxxxxxxxxxxx> wrote in message
news:uplYmP9JIHA.5860@xxxxxxxxxxxxxxxxxxxxxxx
Right.
No, they couldn't. The base class needs to know that this property
exists, because it uses it to validate the type when setting the data.
Without the abstract property, you couldn't write code in the base class
that relies on the property without having the base class be aware of
each and every derived class.
Which was what I was trying to figure out. And this is obviously the
answer as to how the Base Class can tell what the type is.
But I am confused as to how it works.
You actually set _TypeRequired in each class and _ValidateType seems to
know what _TypeRequired is. In _ValidateType, at the line:
Type typeRequired = _TypeRequired;
Before it is actually executed - it seems to know what _TypeRequired is
!!! Yet I can't see where it is actually being set - just defined (either
as abstract or overridden).
It's a property, not a variable, so it is computed each time it is
referenced by calling the getter. The getter is simply "{ return
typeof(bool); }".
As Peter suggested, I was confused by the Debugger which apparently did the
get itself or just figured it out. But that it was this statement that
actually set the _TypeRequired variable - doing the get the very first
thing.
Thanks,
Tom
.
- References:
- Abstract class variables question
- From: tshad
- Re: Abstract class variables question
- From: Peter Duniho
- Re: Abstract class variables question
- From: tshad
- Re: Abstract class variables question
- From: Peter Duniho
- Re: Abstract class variables question
- From: tshad
- Re: Abstract class variables question
- From: Peter Duniho
- Re: Abstract class variables question
- From: tshad
- Re: Abstract class variables question
- From: Peter Duniho
- Re: Abstract class variables question
- From: tshad
- Re: Abstract class variables question
- From: Ben Voigt [C++ MVP]
- Abstract class variables question
- Prev by Date: Re: Abstract class variables question
- Next by Date: Table. Need help with creating it. Thank You.
- Previous by thread: Re: Abstract class variables question
- Next by thread: Re: Abstract class variables question
- Index(es):
Relevant Pages
|
Loading