I have a SDK (GigE C++), which defines a class like this:
class PV_BUFFER_API PvBuffer
{
public:
PvBuffer();
virtual ~PvBuffer();
PvPayloadType GetPayloadType() const;
#ifndef PV_NODEPRECATED
PvResult Alloc( PvUInt32 aSizeX, PvUInt32 aSizeY, PvPixelType aPixelType );
};
The document of the SDK says:
PvResult PvBuffer::Alloc ( PvUInt32 aSizeX,
PvUInt32 aSizeY,
PvPixelType aPixelType
)
Allocates memory for this PvBuffer.
Parameters:
[in] aSizeX The width of the image, in pixels. See GetWidth.
[in] aSizeY The height of the image, in pixels. See GetHeight.
[in] aPixelType The GEV pixel type from which the pixel depth is extracted. For
supported pixel types, see PvPixelType.h.
Returns:
Includes:
PvResult::Code::OK
PvResult::Code::NOT_ENOUGH_MEMORY
I want to use the function Alloc (see the last function in the class). So I am writing like this the program:
PvBuffer *lBuffer; //Class name is PvBuffer
PvResult lResult= lBuffer.Alloc( 1224, 1029, PVPIXELMONO );
But it is giving errors, one of those is:
error C2228: left of '.Alloc' must have class/struct/union
Is syntax correct? Why it is asking for the class?What is the correct way?
leaving aside that this invokes undefined behavior, as
lBufferisn’t initialized, you want:because
lBufferis a pointer.