Cannot be overloaded

I'm trying to create a program that creates an array that behaves like a matrix with the ability to get any value I chose. So far I have run into a problem where I get the error:
"`double* matrix::get(int, int)' and `double* matrix::get(int, int)' cannot be overloaded"
when I try to compile in unix. Any help I could receive to explain why this error is occurring would be greatly appreciated.

#include <iostream>

struct matrix {

protected:
double * * data;
int rows, columns, size;

public:
matrix(int row, int column) {
size = row * column;
columns = column;
rows = row;
data = new double * [size];
}

double * get(int row, int column);
void set(int row, int column, double value);
void resize(int row, int column);
matrix clone();

double * matrix::get(int row, int column) {
if ((row < 0 || column < 0) || (row > rows || column > columns)) {
cout << "Invalid get\n";
return NULL;
}
return data[(row * columns + column)];
}

};

Also, I'm not that great at programming so please forgive my ignorance.

Thank you
I think that the compiler you are using has a bug. It shall not allow to declare a member function with nested name specifier. That is the following declaration is incorrect

double * matrix::get(int row, int column) {


As for the error message issued by the compiler then it considers the following declarations as two overload functions

double * get(int row, int column);
double * matrix::get(int row, int column) {

Place the second declaration that is a definition at the same time outside the class definition.


Last edited on
Move matrix::get() from class declaration.
If you plan to make this an include file, move this to another file
I hadn't realized that was how it was done. I appreciate the help guys. Your responses were clear and concise.
Topic archived. No new replies allowed.