Thursday, March 17, 2011

Wxpython snippet - A date time control

Make sure you have installed wxwidgets.

# Create date control
self.dateCtrl = wx.DatePickerCtrl(panel, -1, pos=(130, 70))

#create time control
self.timeCtrl = wx.lib.masked.timectrl.TimeCtrl(panel,display_seconds=False,
                                               fmt24hr=False, id=-1, name='timeCtrl',
                                     '%X'), pos = (250,70))

To get values -



Monday, March 7, 2011

C++ - Virtual functions

I came across an interesting question in an interview today. It was about virtual functions. I wanted to improve my understanding of virtual functions, so here are some interesting findings, some new and some already known to me.
  • Destructors are called in the order - derived to base(if base destructor is virtual)
  • A virtual function is member function of a class , whose functionality can be overridden by its derived class.
  • The virtual function call is resolved at run time. Unlike non-virtual member functions which are resolved at compile time.(static binding/dynamic binding)
  • If a same 'name' function is implemented in both base class and derived class, the base class function would be called.
  • A class with one or more pure virtual functions becomes an abstract base class. This means that it has to be inherited.
  • An interface class has no members variables, and all of the functions are pure virtual.