Saturday, July 24, 2004

I have heard of the famous urban legend that NASA spent millions of dollars to invent a pen that could be used to write in Space. In space there is no gravity and so the common ink filled pen will not work because gravity will not pull down the ink towards the nib. When NASA was spending this money on the pen research, Russia went ahead and used pencil instead. It served the same purpose at no extra cost!!!

I got it from a book that the site
Fisher Space Pen Co. - Engineered for Better Writing
is of the company that invented the pen for NASA.

The prices on this site says $130 for a pen. That is approximately Rs.5850 in Indian currency. This will be more than the average monthly family income for most Indian household. Even by metropolitan standards that is almost equal to half the salary for a lot of people.

Friday, July 16, 2004

I friend asked me this question.

Write a C++ program that prints "Hello" hundred times without using any loop or recursion statements and obviously without writing the printing statement hundred times.

And the solution is

using namespace std;

class Show
show(){cout <<"Hello" << endl;};

int main()
Show s[100];

I just do not know why someone will ever need this but found it very amuzing. He even went as far as to optimize it by adding the same cout << "Hello" to the destructor and only creating 50 objects instead of 100!!!!!!!

Wednesday, July 14, 2004

C++ - Stop people deriving from your class

One of my friends was facing a problem while trying to write a class B so that no one would be able to inherit from it. He used code as below.

class B; // forward declaration

class Prot // this class is used to stop the inheritance
friend class B; // allow only B access to ctors
Prot(){}; // make all ctors private
Prot(const Prot &p){};

// class that cannot be inherited from
class B: public Prot // inherit from prot. Since B is friend of Prot it'll work
int a;

class D : public B
int d;

D d; // this should fail

However D was still able to inherit from B. What he missed was using virtual inheritance for inheriting from Prot as follows

class B: public virtual Prot // inherit from prot
// ...

this lead to the bug. Without virtual inheritance the call does not go via the vtable and D is able to access Prot's ctor as it is merged with that of B.

Tuesday, July 13, 2004

We knew MS primarily as a secretive organization who is always fighting off Open Source and GNU. But these days they have really gone open thoughts if not open source. Most of them including architects like Herb Sutter have blogs on the net where they speak there hearts out (or is it??)

Check out the following blogs

Brandon Bray Blog
Herb Sutter

Brandon has a nice little piece on the justification of introducing the ^ into C++.
Amazing blog. I don't know from where she(??) gets these links.

Monday, July 12, 2004

I use the CodeProject a lot. One of the maintainers of the site happens to be an Indian who has a interesting blog at

His site is also kinda interesting. May be I'll go and get a domain name for myself one day. Lets see.....

Thursday, July 08, 2004

Give it back

Programers face a slew of problems each day. We either solve it ourself or search the net for resources that better equip us to solve them. The resources could be reference material, books, articles, code snippets or even full fledged application whose source have been given out by a developer.

Some of us take time to thank the kind soul behind the resource via email, but most of use just take it for granted that they are just available. Some even look down upon them considering them as show-offs but still use there material anyway!!!!

But is it not our duty to also give back, from where we are getting so much for so less (actually free). I think it is the moral duty for all developer to give back something to the online developer community. You can always try sites like or