1

I am new to c++ and am writing a procedural program to get the hang of that side of it. I will have a collections of functions that call each other and some include statements, namespace statements, and constant declarations.

My questions are:

What are some guidelines for the file structure of the program ? Should I break this apart with some functions in another file(s) if so are their some standards for what categories of functions deserve their own file?

I hope this question is specific enough. I am NOT looking for the "best" way to do this, just some general guidelines people use.

Thanks so much.

Bren
  • 3,516
  • 11
  • 41
  • 73
  • When you so shopping do you put the bleach in with the chess, etc. Do they split themselves up a bit as into logical units. – Ed Heal Aug 09 '14 at 22:22

1 Answers1

2

Basically, you should group your procedures in some kind of logic and put them together in one file. Then it's a lot easier to read code and it's much more elegant than having only a few extensive files. A good practice is also to make declarations of functions at the top of the file and their definitions at the bottom.

//declarations
void myfun(int a);
/...

//definitions
void myfun(int a)
{
//do sth
}
Savail
  • 867
  • 10
  • 27