user3035035
user3035035

Reputation: 21

How to properly specify which function goes from which file?

The question is about organizing your own code.

Let's say I have multiple *.cpp and corresponding headers to them and I use some functions from these in another parts of program code. After some time passes I may start to forget which header and cpp a certain function goes from and looking at a simple

    func();

tells absolutely nothing.

I can only think of using namespaces so I can later write

    Module::func();

Any other ways? I heard using many namespaces isn't a good practice and a bunch of my projects have more than 5-10 cpp's and headers

Upvotes: 0

Views: 47

Answers (1)

bot_insane
bot_insane

Reputation: 2604

You can change your project to OOP.

Every .cpp file will represent single class. In any part of programm you can see to what object belong called method.

If changing to OOP is problem, you can/must use namespaces. Namespaces only can 'affect' compile-time performance, no other issues can come with it.

Upvotes: 1

Related Questions