Tuesday, June 14, 2005

C++'s One Definition Rule

The one definition rule of c++ is something I learnt and forgot several times, but it makes an interesting read every time!!

More links

The One-Definition Rule

Also see Weaving a Way Past the C++ One Definition Rule

3 comments:

kattricker said...

Pardon me but I am thinking why one would define an entity such as a class more than once, unless by mistake or perhaps when including two libraries where there is a name clash. Java embeds a convenient namespace mechanism in definition of class itself so duplicate definitions are caught at the file system or at compile time. And declaration and definition are the same in Java.

Balbir Singh said...

The definition could be in a header, which in turn could be included by multiple c++ source files.

Balbir Singh said...

Java's convention is good and smart, but it is also kind of limiting and painful at times. I also kind of like their directory parsing

a.b.c.d

for a/b/c/d

Dynamic programming for the binomial coefficient

More fun things, this time with some visualisation of what happens when memoisation is used and what happens when we don't. I don'...