How to inherit from 7.12's rpreview class?

How to inherit from 7.12's rpreview class?

Postby hua » Wed Jan 02, 2008 2:49 am

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
hua
 
Posts: 1072
Joined: Fri Oct 28, 2005 2:27 am

Postby Antonio Linares » Wed Jan 02, 2008 12:19 pm

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
User avatar
Antonio Linares
Site Admin
 
Posts: 42107
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby StefanHaupt » Wed Jan 02, 2008 12:41 pm

Antonio,

what is the difference between CLASSDATA and DATA ?
When I have to use CLASSDATA ?
kind regards
Stefan
StefanHaupt
 
Posts: 824
Joined: Thu Oct 13, 2005 7:39 am
Location: Germany

Postby Antonio Linares » Wed Jan 02, 2008 1:00 pm

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
User avatar
Antonio Linares
Site Admin
 
Posts: 42107
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby hua » Thu Jan 03, 2008 5:36 am

Thanks for the reply Antonio
hua
 
Posts: 1072
Joined: Fri Oct 28, 2005 2:27 am

Postby StefanHaupt » Thu Jan 03, 2008 12:54 pm

Antonio,

Ok, I see.

Many thanks for the explanation
kind regards
Stefan
StefanHaupt
 
Posts: 824
Joined: Thu Oct 13, 2005 7:39 am
Location: Germany


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 33 guests