timer allocation

I am wokring on a project using native c++ and running on a OS similiar to Linux. I am designing a gui using native c++ programming. I have a base class B which draws the base form, and it has a timer to indicate time, date, and month. The ten derived class D0 to D9 show different forms based on user selection, all of them use base form defined by class B. The pseudo code looks like the following:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
class B
{
   private:
    Timer tm;
   
   //draw base form and use tm to show the time and date in base form
   ...
};

class D0 : public class B
{  //use base form defined by class B, and add more details for class D0
};
...
class D9 : public class B
{ //use base form defined by class B, and add more details for class D9
};


My question is for OS resource, how may timer is actually allocated, one (base timer) or eleven (10 derived plus one base), or two (one base, plus one active form)? Please note that all the ten derived classes are instanciated, but each time only one form is active.

I think OS just allocated one timer, D0-D9 inherits class B, no additional timer is allocated for the derived class. Is it correct? Any help or comment will be appreciated.
Last edited on
how may timer is actually allocated, one (base timer) or eleven (10 derived plus one base), or two (one base, plus one active form)?
One for each instance of the base or derived class.
If you want to allocate just one Timer that will be shared by all instances, make B::tm static.
I see. So there is one timer allocated for each instance and it will use a lot of OS resources if it is not designed properly.
Topic archived. No new replies allowed.