Quantcast
Channel: Active questions tagged header - Stack Overflow
Viewing all articles
Browse latest Browse all 705

When is it acceptable to define a function in a header file? [duplicate]

$
0
0

Good Evening,

Im new to C++ but I was under the impression it was a no go to Define functions within header files.

I've been looking at some open source code and it seems a class has been defined within a header file and not split into .h / .cpp.

class Action{public:    virtual ~Action() {}    virtual string GetName() { return "Action"; }    virtual void RequestUpdate(ActionContext* context) {}    virtual void Do(ActionContext* context, double value) {}    virtual void Touch(ActionContext* context, double value) {}    virtual double GetCurrentNormalizedValue(ActionContext* context) { return 0.0; }    virtual double GetCurrentDBValue(ActionContext* context) { return 0.0; }    int GetPanMode(MediaTrack* track)    {        double pan1, pan2 = 0.0;        int panMode = 0;        DAW::GetTrackUIPan(track, &pan1, &pan2, &panMode);        return panMode;    }};

There seem to be many other header files defining functions in the same project. Am I missing something here?

Full Header File HERE


Viewing all articles
Browse latest Browse all 705

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>