c++ initiliazation what do you call it

Started by
12 comments, last by Aardvajk 11 years, 8 months ago
struct Some_Event** events = NULL, *event;

is a good example for one importat issue to remember: the * doesnt jump over to the next variable


so if u do

int *a, b, *c

you create an int pointer a, a regular int b and an another int pointer c

can be quite confusing.

I open sourced my C++/iOS OpenGL 2D RPG engine :-)



See my blog: (Tutorials and GameDev)


[size=2]http://howtomakeitin....wordpress.com/

Advertisement

there is probably a reason this syntax is not recognized in the bjarne stroustrop official reference book.

Yes, indeed. Professor Stroustrup prefers to convey only good practices and beneficial uses of the C++ programming language. In fact, he does discuss the multiple-declaration syntax in my copy of his book "The C++ Programming Language" and recommends against its use for all the same reasons documented here.

Stephen M. Webb
Professional Free Software Developer

It is a common feature of many languages that you can declare multiple variables of the same type on one line.
In Pascal one would do it as:
var
a, b, c: integer;
"In order to understand recursion, you must first understand recursion."
My website dedicated to sorting algorithms

I wanted to expose how the syntax does not hold up. Seems like it was tacked on as an afterthought.


Not really. Back in the days pre-C99 when you had to declare all your local variables at the top of a scope block before any statements, it was probably quite common to declare variables on one line. It is also fairly trivial for the parser to implement so is, like many features of C and C++, there if you want it, don't use if you don't.

Stroustrup often makes the point that the language does not dictate to the programmer the style in which s/he should code.

This topic is closed to new replies.

Advertisement