Menu Alignment

My answer to the question Why all menus in windows are floating left with dual monitor? was not quite right. The author of the question commented my answer and updated the question with the screen shot of the entire desktop.

Menus on their desktop are right-aligned, and it’s not because the menu would fall out of screen with left-alignment.

Usually, menus are left-aligned:
Left-aligned Help menu in Notepad

But menus can be right-aligned:
Right-aligned Help menu in Notepad

Windows allows changing alignment of the menus, but it provides no UI to control this setting.

So to fix user’s problem, I wrote a simple application MenuAlignment.exe.

Read the rest of this entry »

Advertisements

C++: calling methods from constructors

One and a half months ago I posted a question on Java. Now it’s time for its counterpart in C++:

#include <tchar.h>
#include <iostream>

using namespace std;

class Parent
{
public:
    Parent()
    {
        test();
    }

    virtual void test()
    {
        cout << "Hello from parent\n";
    }
};

class Child : public Parent
{
private:
    char *name;

public:
    Child()
    {
        name = "Hi";
    }

    virtual void test()
    {
        cout << "Hello from child " << name <<  "\n";
    }
};

int _tmain(int argc, _TCHAR* argv[])
{
      Child();
      return 0;
}

What does it print?
The answer is obvious if you compile and run it? Can you answer it without running?