LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-03-2010, 01:20 PM   #1
bluegospel
Member
 
Registered: Jan 2010
Distribution: centOS
Posts: 404

Rep: Reputation: 53
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?
 
Old 07-03-2010, 01:33 PM   #2
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by bluegospel View Post
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.
 
1 members found this post helpful.
Old 07-03-2010, 02:09 PM   #3
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
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;
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
pointer syntax 1mela Programming 7 02-03-2010 10:15 AM
[python] syntax Error : invalid syntax Python_user Programming 2 09-06-2009 12:52 PM
pass pointer,, return pointer??? blizunt7 Programming 3 07-23-2005 01:36 PM
returning data to main() via a pointer to a pointer. slzckboy Programming 3 05-30-2005 01:20 PM
hot to set value of pointer to pointer to a structure in C alix123 Programming 2 11-17-2004 06:40 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:30 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration