OK, this is my first poll. I'd like to know how you declare pointers. I'll start. I use:
char* name;
I put the * next to the type mainly to make clear that it's not the defference (sp?) operator.
How about you?
char* name;
char *name;
char * name;
Other (plz post)
OK, this is my first poll. I'd like to know how you declare pointers. I'll start. I use:
char* name;
I put the * next to the type mainly to make clear that it's not the defference (sp?) operator.
How about you?
SoKrA-BTS "Judge not the program I made, but the one I've yet to code"
I say what I say, I mean what I mean.
IDE: emacs + make + gcc and proud of it.
When you haveit looks as if both a and b is of type char*, but actually b is only of type char. To avoid confusion, rather useCode:char* a,b;to more clearly show what you meanCode:char *a, b;
char *something;
There are some real morons in this world please do not become one of them, do not become a victim of moronitis. PROGRAMMING IS THE FUTURE...THE FUTURE IS NOW!!!!!!!!!
"...The only real game I thank in the world is baseball..." --Babe Ruth
"Life is beautiful"-Don Corleone right before he died.
"The expert on anything was once a beginner" -Baseball poster I own.
Left cprog on 1-3-2005. Don't know when I am coming back. Thanks to those who helped me over the years.
Always...
type* pVariableName;
... and one declaration per line - no confusion.
Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.
I used to use
Type *variable;
but i've heard it's better to use
Type* variable;
Plus, it makes more sense in many cases. I've been trying to change my habits towards the latter, but now and again I find myself typing Type *var.
Well maybe I should change my habits as well.....any idea why this way char* var; might be better?
There are some real morons in this world please do not become one of them, do not become a victim of moronitis. PROGRAMMING IS THE FUTURE...THE FUTURE IS NOW!!!!!!!!!
"...The only real game I thank in the world is baseball..." --Babe Ruth
"Life is beautiful"-Don Corleone right before he died.
"The expert on anything was once a beginner" -Baseball poster I own.
Left cprog on 1-3-2005. Don't know when I am coming back. Thanks to those who helped me over the years.
i've heard that 'type *var' is better, because you're only making that variable a pointer, not everything in that decliration, so it makes more sense to keep the * with the single variable. makes sense to me.. it's what i've always used.
If I had a world of my own, everything would be nonsense. Nothing would be what it is, because everything would be what it isn't. And contrariwise, what it is, it wouldn't be, and what it wouldn't be, it would. You see?
I use
Code:std::string name;
Seriously, I think char* name looks best and I never declare pointers and non-pointers on the same line anyway.
Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling
Purely asthetics, but I always place the asterisk between the type and variable:
const char * str;
void Foo(int * x);
...etc...
That's the best practice....and I never declare pointers and non-pointers on the same line anyway.
Code:#include <cmath> #include <complex> bool euler_flip(bool value) { return std::pow ( std::complex<float>(std::exp(1.0)), std::complex<float>(0, 1) * std::complex<float>(std::atan(1.0) *(1 << (value + 2))) ).real() < 0; }
I usually use char *pointer. But once in a while there comes a time that I need to use char* pointer.
I never include non-pointers and pointers on same line either.
It really depends on you... since they are all correct, just choose what's more suitable to you...
I prefere char *
none...
char * duh;
//i'll do multiple decl's of anything but pointers
int a,b,c,d,e;
bool go,stop,rewind;
float * info;
float * theNum;
PHP and XML
Let's talk about SAX
I usually use
char* pointer
because the * makes it a separate datatype. Putting it adjacent to char makes the type information close together and separate from the variable name.
For multiple line declarations I usually do something like this:
Code:char Data, * Pointer;
char* always;
for clarity if i have a char and a char* i put them on seperate lines
char* p,* q;
char c, ch;
ADVISORY: This users posts are rated CP-MA, for Mature Audiences only.
No difference between the two. But for the sake of declaring multiple pointers in one line, I use the *var method.
I AM WINNER!!!1!111oneoneomne