Defining a function that is a member of a class

I have two functions that are private members of the Data class:

class Date
{
private:
    bool leapYear(int y);
    void fillDate(int d, Month m, int y);
};

So, where is the best place to define these functions:

  • in the class definition;
  • in the header file outside the class;
  • or in a .cpp file?
+4
source share
3 answers

You have a choice here. Here are some ideas to help you understand:

  • Attachments for speed are no longer an issue, as compilers are now well-suited for optimizing connection times. Thus, performance should not be a factor in making decisions here (compilation speed is also important, but this is another bag of worms).
  • -, , "" , . , , , . .
  • , , , , , . .
  • Pimpl , . .

, , inline . ( ".cpp" ), .

inline, - , .

+4

2. " " , , () .cpp .

+1

, (.cpp), , , (+ ) , IMO, , -, ( ) . , , , , , / . , , .

0

All Articles