N
NewToCPP
I have the following code. It complains that there is Possible use of
null pointer. How to handle "operator []" returning reference to the
null pointer?
class my_data
{
private:
my_period* period;
public:
my_period& operator[] (unsigned int);
};
my_period& my_data:perator[] (unsigned int i)
{
if (period==0)
{
print_error("error");
}
return period;
}
null pointer. How to handle "operator []" returning reference to the
null pointer?
class my_data
{
private:
my_period* period;
public:
my_period& operator[] (unsigned int);
};
my_period& my_data:perator[] (unsigned int i)
{
if (period==0)
{
print_error("error");
}
return period;
}