C++ frequently questioned answers

Ary Borenszweig ary at esperanto.org.ar
Sat Oct 27 05:16:47 PDT 2007


Bruce Adams escribió:
> Walter Bright Wrote:
> 
>> An interesting and sometimes amusing read:
>>
>> http://yosefk.com/c++fqa/
> 
> In amongst the religous fervour (of the defective C++ bit) there are some genuine points. The amusement comes from the obviously java biased/blinded viewpoint of the author. It seems to me the main retorts to this fqa is the C++ is spiderman retort "With great power comes great responsibility" another less polite one that comes to mind is the Harry Hill retort "If its too hard I can't understand it". Templates add a whole new dimension to typing that flatlanders find hard to grasp at first.
> Leaving the poor education aside D seems to address all the genuine concerns except reflection and inlining. I know reflection will be added eventually but what about inlining. Isn't inlining available via mixins?
> 
> [OT]
> Someone at work pointed out this java chestnut recently. If you've used java much you will know it but it may come as a shock to a mainly C++ coder.
> 
> class foo {
>     bar x;
>     void foo () {
>         x = new bar();
>     }
> }
> 
> foo is NOT a constructor its actually a method named foo. The java compiler or interpreter generates a default constructor that sets all members to null so any use of x in any method of foo will result in a null pointer exception. This apparently compiles with no warnings.
> [/OT]

In D:

class Foo {

private {
	int x, y;
}

static {
	float SomeGlobalVariable;

	this() {
		// Do some global initializations
	}
}
}

Nope, no compiler warning here either.

At least Eclipse gives you a warning saying "That method's name is the 
same as the class' name". :-)



More information about the Digitalmars-d mailing list