Hi !

I have a base class and a derived class ( which inherits the base class ).

I want to derived class to overload the [] operator, so that it can perform certain operations and also call the [] operator of the base class. I have used to BaseClass before and I know it isn't the source of the problem. I have abreviated some code with ( ... ) when I felt it was not necessary to put said code.

Here is what I have done so far :

Code :
DerivedClass.h
Code:
template <typename T>
DerivedClass : public BaseClass<T>
{
public :
	...
	...
	...
T &operator[] (int param);
};
DerivedClass.cpp
...
...
...
Code:
template <typename T>
T &DerivedClass<T>::operator[] (int param) 
{
...
...
...
}
Main.cpp
Code:
...
DerivedClass test();
...
test[i] = 12;
...
But I get a Segmentation Fault everytime I run the program.
I have removed all code in the overloaded operator [] in the derived class so I know this is not the problem.
If I call test[i] = 12 I get a segfault even if [] does not have any code in it's implementation.
If I don't call [] I don't have any problems.
I have tried different values, etc. but after some extensive testing I can see the problem is not there.

I have no idea what I could be doing wrong... but I really have close to no experience overloading operators and working with templates so I'm no surprised it's not working.

I would appreciate any help you could give me, thank you in advance !