I'm not sure what topic this question falls under so I'm forced to post it as a general C++ programming item. If there is somewhere else I should be posting this, or an existing topic of this kind, I apologise.
I am in the process of mapping out a scientific library of sorts. My background is Astrodynamics (study of motion of objects in space) and there are a number of functions, classes, sections of code that I would like to standardize so that I can maintain a library that can be used efficiently in my research group.
To this end I want to set up a template of standards/protocols so that anyone adding to the library in my group can maintain the same form as everyone else.
I have at the moment reduced this down to producing a file template for a header file and a source file in C++. Basically this means I want to setup a general format for the structure of such a file, e.g., a template for the documentation at the top of the file including things such as a description of the file, date of creation, date of last modification, copyright info, change log etc.; a template for the way classes are laid out, including documentation of coding; a template for the way functions are laid out; a template for variable names etc. etc.
I was wondering if anyone has a good resource for the way such elements should be standardized, for it to both be effective and concise as a medium to communicate code in a shared library. I have found a few resources but they pertain to general applications and I am looking specifically for a protocol relating to scientific code.
I think this sort of stuff is usually mandated by whoever you are working for. The key here is that it's better if all the code is consistent; if you are working with any code already written, then you should probably use the same format it uses.
If you are writing from scratch for yourself, you would probably be well off just looking around online for code samples and picking a documentation style you like the best.
Thanks for your responses. I guess the issue is that the coding standard documents I have found thus far have pertained to general applications. In addition, I haven't really found any coding standards that describe how to use comments in a C++ file e.g., the comments provided at the top of the file that I listed in my initial post.
If anyone knows of any resources for coding standards for scientific purposes and/or coding standards that provide examples of how to lay a source file out, I would really appreciate your input.
Hi,
i want to share tip relating to C++.Hope you find it useful.
Viewing all elements of dynamically allocated arrays In VC++
Normally when you allocate an array dynamically, and then look at the variable in the watch window you can only see the first element. But if you want to view the entire array just type the <variable-name>, <number-of-elements-to-view>.
Example
void main( void )
{
const int SIZE = 10;
int *intArray = 0;
for( int x = 0; x < SIZE; x++ )
{
intArray[x] = 10 + x;
}
return 0; // put a break point here, so that control stops here and
// we can see the "intArray" contents in "Watch" window
}
Watch Window: Debug -> Windows -> Watch ->
to see intArray in the watch window type
intArray, 10
and now we can see all the 10 elements of "intArray" in watch windows.