PDA

View Full Version : organized or no?



drarem
21st June 2007, 19:18
The thing that skeered me away from mfc was the c++ - class overrides, multiple files were created for different things like view, io, etc.. I went with win32 (one .cpp and one or more .h files )..

Can I put everything into one .h and one .cpp file - at the risk of answering my own question, probably yes but it won't be easily maintainable.

When would I know to put an aspect of my application in its own file/class?

magland
21st June 2007, 19:37
When would I know to put an aspect of my application in its own file/class?

In my experience, it's better to err on the side of creating too many files, because it encourages modularity. It's good to organize your development style so that creating/managing a new file is not a penalty.

Brandybuck
22nd June 2007, 03:10
The traditional C++/Java/OO approach has been one header (.h) and one implementation (.cpp) file per class. If you design your classes sensibly, this makes maintenace easier.

BrainB0ne
22nd June 2007, 16:11
The traditional C++/Java/OO approach has been one header (.h) and one implementation (.cpp) file per class. If you design your classes sensibly, this makes maintenace easier.

Thats the method i would stick too mostly, there are some exceptions though.... for example if i subclass a QListView and use also subclassed QListViewItem's i put them together in one .cpp and .h file. But i prefer to have one cpp and h file per class.