Sunday, April 26, 2009

A few C++ Quirks

It's very usual in Java to initialize something which is constant throughout the class as static const within the class definition in the following way:

private static final String MAX_THREADS = 5;

After coding in Java for BlackBerry development for a few months, when I started working with C++ Qt framework, I did it in the same manner:

static const QString TITLE_TEXT = "Title Text";

I got the error - only static const integral data members can be initialized within a class. Google led me to the following solution:

1) declare in header file - static const QString TITLE_TEXT;
2) initialize in cpp file - const QString ClassName::TITLE_TEXT = "Title Text";

In the second step, I tried prepending static but got error - 'static ' storage-class specifier illegal on members.

In Java, the mechanism of indirection for constructors is as simple as calling this() with necessary arguments. We often do this to keep the initialization code in only one place. In C++, when tried, I got the error - term does not evaluate to a function taking 3 arguments. When I replaced this with a custom function initialize() where all the initialization code were put together, it worked fine.

Working with multiple languages sometimes does give trouble :-(

Thursday, April 9, 2009

BlackBerry Development : error - Cannot run program "javac"

I had been away from BlackBerry development for about a month. In the mean time, I bought a new PC. Having installed BlackBerry JDE, I wrote a simple program. Then tried to build it. But as you know, error happens :(

I/O Error: Cannot run program "javac": CreateProcess error=2, The system cannot find the file specified

And then I recalled that jdk bin directory had not been added to the Path environment variable. I added C:\Program Files\Java\jdk1.6.0_02\bin , then built the project. The same error shows up again. Then I closed and reopened the workspace, built it. No luck. Then closed JDE, restarted JDE, opened the workspace, built the project and only then everything was fine!

Silly matters sometimes do cause trouble!

Monday, April 6, 2009

M. A. Latif is a member of the parliament


I've just gone through the story of parliament member M. A. Latif's obnoxious behavior in today's issue of Prothom Alo. (I could not provide the link of Prothom Alo's version since it seemed to me that their link does not work later.)

What Mr M. A. Latif can do to remind the people of his constituency, if not the whole nation, of his vibrant presence outside the parliament as a parliament member :

1. Include a chapter on his 'glorious' life so far in the textbooks for all classes. The students will read the same chapter in every class they pass. This chapter on M. A. Latif's life story and his contribution to the nation, in a broader sense to the world and humanity, will surely be a favourite one since the students will have to memorize a chapter less in every class if he can memorize the answers to questions of this chapter.

2. In front of his house, he may establish his statue and people passing by this statue must salute / offer 'salam' to it. People not performing this holy duty should undergo punitive measures like outright slap on the spot, saluting 10 times etc. To enforce this, some extra law-enforcers will be required and this will solve the unemployment problem for some people. Just imagine that in this time of recession and hardship, Mr M. A. Latif is offering job opportunities to some people and thus helping the humanity to survive!

3. I can't understand why Mr M. A. Latif condescends to talk himself to the people when he gets angry/misbehaves. He can appoint one of his party men for staging a outragious show of crude and rude behavior. Then the wicked newspapers will not able to say that Mr M. A. Latif misbehaved with A, B, C etc. because he didn't do it!

(Don't feel writing about this inferior instance of human being anymore... ... ... apology)