Bjarne Stroustrup's Replies

I believe in making use of the www and email to the most. I really like getting lost in the www.
One instance of its application is that I could clear my queries over something from the founder itslef!
See Bjarne Stroustrup giving me some tips!

> Subject: Programming Style Query
> Importance: high
> X-Priority: 1
> MIME-Version: 1.0
>
> bs..
> if u can spare a few minutes from ur schedule, tell me
> How would you put the braces after statements - in java style or good old C
> style? and why
>
> java style:
> 	public static void main(String[] arg){   // '}' in same line
> 	}
> C style
> 	int main()
> 	{
> 	}

as you will see from my books and papers, I put function braces on separate
lines and statement braces on the same line (as what comes before):

int f(int i)
{
	if (i) {
		// ...
	}
}

Basically, my style is K&R style. Not surprising since I worked with them for
years.

> Subject: Inheritance Query
> MIME-Version: 1.0
>
> Hi B.S,
> 	if you can spare some time,
> 	Got one query- went through your FAQ site, but not found a topic
> related to this.
> 	my doubt is:===>
> 	can we make a class in C++ un-inheritable?how?
> 	(like in java classes can  be 'finalize'd.)
> thankx
> ranjith.

You can, but not elegantly (see D&E 11.4.3, the basic idea is that you cannot
inherit a private destructor). The reason is that C++ doesn't need such a
feature anyway as much as Java does. C++ has non-virtual member functions, and
C++ virtual function calls are fast enough not to need such a facility for
efficiency reasons.