LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   pointer syntax (C++) (https://www.linuxquestions.org/questions/programming-9/pointer-syntax-c-817853/)

bluegospel 07-03-2010 01:20 PM

pointer syntax (C++)
 
I've seen all three uses:

type * pointer
type *pointer
type* pointer

Are these 3 forms essentially the same, i.e., is the spacing as used here a non-factor when declaring pointers?

Sergei Steshenko 07-03-2010 01:33 PM

Quote:

Originally Posted by bluegospel (Post 4022959)
I've seen all three uses:

type * pointer
type *pointer
type* pointer

Are these 3 forms essentially the same, i.e., is the spacing as used here a non-factor when declaring pointers?

Whitespaces do not matter in C/C++ - except in string.

johnsfine 07-03-2010 02:09 PM

Whitespace doesn't matter in type*pointer.

But obviously there are places in C++ outside of strings where whitespace does matter. For example, whitespace is not valid in a digraph, and in obscure cases whitespace is required to prevent two operators from being a digraph. The following code is wrong due to lack of required whitespace:
Code:

std:vector<std::vector<double>> matrix;


All times are GMT -5. The time now is 06:25 PM.