-
Your Coding Style?
What kind of coding style do you like to use in the following situations?
1.)
Code:
A.)
void Function(){
//myCode
}
//-----------------------------
B.)
void Function()
{
//myCode
}
2.)
Code:
A.)
int *myPointer
//-----------------------------
B.)
int* myPointer
//-----------------------------
C.)
int * myPointer
3.)
Code:
A.)
if (condition == false)
//-----------------------------
B.)
if (!condition)
4.)
Code:
A.)
const char msg[] = "Welcome to Utah.";
//-----------------------------
B.)
const char *msg = "Welcome to Utah.";
5.)
Code:
A.)
void Function(int& x){
x = 25;
}
int main(void){
int x=0;
Function(x);
return 0;
}
//-----------------------------
B.)
void Function(int *x){
x = 25;
}
int main(void){
int x=0;
Function(&x);
return 0;
}
My answers would be:
1 - A
2 - A
3 - A
4 - B
5 - A
-
1) A
2) A
3) B
4) B
5) B (A is C++ only)
-
1) B
2) A
3) B
4) B
5) A & B :)
-
B
A
B
A
5b wouldn't have the same effect as 5a by the way.
-
-
Stop trying to be like me thantos.
-
1) B
2) A
3) B
4) B
5) A (with obligitory B answer as well)
-
-
-
A
A
B
B
Arn't they essentialy the same?
-
-
Code:
void Function()
{
//myCode
}
Code:
LPCTSTR lpszMessage = _T("Welcome to Utah.");
Code:
void Function( int& nX )
{
nX = 25;
}
int main()
{
int nX = 0;
Function( nX );
return 0;
}
Edit: daveP special: ... and yes, a horse is a miscapitalized HANDLE to an Orse. It should read hOrse.
-
1. B (I like symmetry)
2. B (the * is a part of the type name)
3. B
4. none (STL strings)
5. A (use references instead of pointers where possible) (also my code usually compiles, unlike 5B :) )
-
1. B
2. B
3. B
4. Depends.
5. A
-
> 2. B (the * is a part of the type name)
int* p,i;
What type is i?
If you're thinking i is a pointer, think again.