Question

following is my header file

#ifndef _ASYNCHRONOUSCLASS_H
#define _ASYNCHRONOUSCLASS_H
#include "stdafx.h"
#include <windows.h>

typedef int (*functionCall)(void *);
typedef void * voidPtr;

class  AsynchronousFunction{    
//int returnVal; 
//functionCall fCall;
//voidPtr param;
//HANDLE m_hEvent;

struct pImpl;
pImpl* m_pImpl;

public:
    AsynchronousFunction(functionCall fCall, voidPtr param);
    ~AsynchronousFunction();
    void functionExecuter();
    int result();

protected:
private:    
};
#endif

In the cpp file I want to implement the struct which contains following details.

*//int returnVal;* 
*//functionCall fCall;*
*//voidPtr param;*
*//HANDLE m_hEvent;*

How can I implement this ? What would be suitable, forward declaration or pointer implementation ?

Was it helpful?

Solution

In a single translation unit you will need to provide the definition of the type. It will look like:

struct AsynchronousFunction::Impl {
   // members and functions...
};

Note that I renamed pImpl into Impl, the p in the idiom is for pointer, the member in the containing class would be Impl* pImpl;.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top