hello, i have this class called MemoryManager,
it is supposed to implement a simple smart pointer, (count reference);
i have a vector where i store the requested pointers,and i return the index of the pointer to the caller..
when a user creates a pointer of type MemoryManager he calls an initializer function called modified_malloc(size_t) , create a MemoryManager obj, alloc a memory space and store it into data,increase count, and store the object into global_MM_vecotr , and return the index as a pointer , when the use tries to use indirection ( ->) i return the appropriate real pointer from the vector, according to the index value..
class MemoryManager
{
public:
//operators overloading prototypes
private:
void* data;
int count ;
};
std::vector<MemoryManager*> global_MM_vecotr;
void* MemoryManager::operator=( void* x)
{
// some code here
}
the problem i am facing is that i overloaded a couple of operators, however when i try to run the code below the "=" operator doesn't get called.. can some1 point the problem out to me..
//the main code
{
MemoryManager* obj1 = (MemoryManager*) x->fun1(4); //fun1 returns an index to a MemoryManager obj in a vector;
MemoryManager* obj2 = obj1 ;
}
Edit: already tried the following , no change
{
MemoryManager*obj1 = (MemoryManager*) x->fun1(4); //fun1 returns an index to a Class obj in a vector;
MemoryManager*obj2 ;
*obj2 = *obj1;
}
{
MemoryManager* obj1 = ( MemoryManager*) x-> fun1(4);
MemoryManager* obj2;
obj2.operator =(*obj1);
}