I'm trying to return an array, but I'm getting errors when I actually try to use the method.
The error:
The code:Quote:
318 C:\Dev-Cpp\Projects\Histography\main.cpp instantiated from here
The error:Code:char* possible_array = hist.get_least_obj_occurances();
The code:Quote:
151 C:\Dev-Cpp\Projects\Histography\main.cpp invalid conversion from `const char' to `char*'
It specifically catches on that one bold line.Code:template <typename T> T* Histogram<T>::get_least_obj_occurances()
{
typename map<T,int>::iterator ci;
int same_occur = get_same_occurances(0);
int low = get_least_num_occurances();
T return_array[same_occur];
if (same_occur = 1)
{
for (ci=frequency.begin(); ci != frequency.end(); ++ci)
{
if (ci->second == low)
{
return ci->first;
}
}
}
else
{
int index = 0;
for (ci=frequency.begin(); ci != frequency.end(); ++ci)
{
if (ci->second == low)
{
return_array[index] = ci->first;
++index;
}
}
}
return return_array;
}
I'm creating the array with the following line:
Where hist is a histogram object of type char.Code:char* possible_array = hist.get_least_obj_occurances();
If someone can help me with this it would be much appreciated.
