user2381422
user2381422

Reputation: 5805

Is it OK to place more classes in one .h file, or more structs in one .h file?

Is it OK to place more classes in one .h file, or more structs in one .h file?

I have two simple structs, and right now I have separate .h and .cpp files for both. Initially they were classes and not structs, but because everything is public I decided to make them public.

Please give me some suggestions.

Thanks

Upvotes: 0

Views: 162

Answers (3)

anand madhab
anand madhab

Reputation: 5

yes we can have multiple classes as well as multiple structures in a h file.

Upvotes: 0

Frankenstein
Frankenstein

Reputation: 430

There's nothing wrong. An header file may contain more than 1 classes..! Go ahead :)

Upvotes: 5

Griffin
Griffin

Reputation: 14634

If the structs/classes are related to one another then stick them in the same file - makes sense.

Think of it like packages in java.

Upvotes: 0

Related Questions