How to inherit from 7.12's rpreview class?

Post Reply
hua
Posts: 861
Joined: Fri Oct 28, 2005 2:27 am

How to inherit from 7.12's rpreview class?

Post by hua »

I have a customized version of rpreview, which has a few additional buttons.

Seeing that rpreview in 7.12 is now a class, I attempt to inherit from it and place my changes in this new class. So I create a new class TPreview2, copy over method ::BuildButtonBar() and started to add in the additional buttons.

What stump me during this attempt is l2007 is declared as a static var in TPreview not as a class data. What's the correct way for me to proceed? Simply create a static l2007 var in TPreview2 or modify TPreview and change the var to a class data?

What's actually the rule of thumb when inheriting classes that make use of static vars? TPrinter is another class that comes to mind.

TIA
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Hua,

> What's the correct way for me to proceed?

Yes, you can declare it as a CLASSDATA and modify the source code to access ::l2007

There is nothing wrong in using static vars. The problem comes when a class is inherited, as in your case. Then, you are right, a CLASSDATA is the way to go
regards, saludos

Antonio Linares
www.fivetechsoft.com
StefanHaupt
Posts: 824
Joined: Thu Oct 13, 2005 7:39 am
Location: Germany

Post by StefanHaupt »

Antonio,

what is the difference between CLASSDATA and DATA ?
When I have to use CLASSDATA ?
kind regards
Stefan
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Stefan,

A DATA belongs to an object. A CLASSDATA belongs to a Class.

For example:Imagine that you want to create a class TCar, and you want to know how many cars have been produced. Then you need a CLASSDATA nCars that will be a "shared" value from all Cars objects.

So everytime that a car is created, you do oCar:nCars++ and nCars is the same CLASSDATA shared from all Cars objects.

There are multiple cars, and just one nCars value.
regards, saludos

Antonio Linares
www.fivetechsoft.com
hua
Posts: 861
Joined: Fri Oct 28, 2005 2:27 am

Post by hua »

Thanks for the reply Antonio
StefanHaupt
Posts: 824
Joined: Thu Oct 13, 2005 7:39 am
Location: Germany

Post by StefanHaupt »

Antonio,

Ok, I see.

Many thanks for the explanation
kind regards
Stefan
Post Reply