I believe this is not strictly specific to DirectX but just to pure c++ language problem.
I have a class (simplified):
class A {
public:
ID3D11Buffer* getVBuffer() const {
return m_vbuffer;
}
// I will make this public for this example
ID3D11Buffer* m_vbuffer;
};
and then in some other place I am creating vertex buffer:
device->CreateBuffer( ..., &instanceOfA->m_vbuffer );
it works ok, but why with the getter method doesn't?
ID3D11Buffer* _vertexBuffer = instanceOfA->getVBuffer();
device->CreateBuffer( ..., &_vertexBuffer );
it crashes at Map function with access violation, but I'd like to have getter method used.
// EDIT
when I wrote like this:
device->CreateBuffer( ..., &instanceOfA->getVBuffer() );
the compiler (VS2012) told me:
error C2102: '&' requires l-value
Is it then even possible to use getters in this situation?