From: morgado AT mail DOT telepac DOT pt (Jorge Bruno S. S. Morgado) Newsgroups: comp.os.msdos.djgpp Subject: Operator overloading problem Date: Tue, 25 Aug 1998 19:34:05 GMT Lines: 81 Message-ID: <35e30d75.267206@news.telepac.pt> NNTP-Posting-Host: 194.65.172.91 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Can you tell what is wrong with this code: I've made a class called Matriz, like this: #define MIN_LINHAS 2 #define MIN_COLUNAS 2 class Matriz { protected: double *matriz_ptr; unsigned linhas; unsigned colunas; public: Matriz(unsigned i = MIN_LINHAS, unsigned j = MIN_COLUNAS): linhas(i), colunas(j) {matriz_ptr = new double[linhas * colunas];} ~Matriz() {delete[] matriz_ptr;} unsigned n_linhas() const {return linhas;} unsigned n_colunas() const {return colunas;} double& operator()(unsigned linha, unsigned coluna) {return *(matriz_ptr + (linha-1) + (coluna-1) * linhas);} friend bool operator==(Matriz&, Matriz&); }; bool operator==(Matriz &a, Matriz &b) { int i, j; if(b.n_linhas()!=a.n_linhas() || b.n_colunas()!=a.n_colunas()) return(false); for(i=1; i<=a.n_linhas(); i++) for(j=1; j<=a.n_colunas(); j++) if(a(i,j) != b(i,j)); return (false); return(true); } And in main i've put something like this: void main() { Matriz A(2, 3); Matriz B; A(1,1) = 11; A(1,2) = 12; A(1,3) = 13; A(2,1) = 21; A(2,2) = 22; A(2,3) = 23; if(A == B) cout << "\n\nB = A"; if(c != y) cout << "\nB != A"; } But the problem is that when I try to compile, it gives the following error: Error: A undeclared (first use this function) Error: B undeclared (first use this function) Do you know what is wrong with this code ?