I currently have two different headers defining the same class. What changes between them is the functions implementation and a single variable.
header_linux.h
class Class
{
private:
    QStringList processesList; // Same variable
    pid_t pid; // Different variable
public:
    void fillProcessesList()
    {
            // Different implementation
    }
    void isProcessRunning(QString name)
    {
            // Same implementation
    }
    template<typename T>
    bool readMemory(unsigned long long address, T &destination)
    {
            // Different implementation
    }
header_win32.h
class Class
{
private:
    QStringList processesList; // Same variable
    HANDLE handle; // Different variable
public:
    void fillProcessesList()
    {
            // Different implementation
    }
    void isProcessRunning(QString name)
    {
            // Same implementation
    }
    template<typename T>
    bool readMemory(unsigned long long address, T &destination)
    {
            // Different implementation
    }
I would like to have the common variables and functions in a single file.
My idea was to create header.h which defines the class and its members, header.cpp which implements the common functions and then header_linux.cpp and header_win32.cpp which implement the OS-specific functions.
However, template functions must be implemented in the header file.
I could check the operating system using a preprocessor macro and according to that use the right implementation, in a single header, but the functions are many and their body is big.
After a lot of research I found the PIMPL idiom, but the implementation seems complicated.
Is there a better way?
 
    