From: hgfernan AT usp DOT br Message-Id: <9712141619.AA18394@spider.uspnet.usp.br> Comments: Authenticated sender is To: djgpp AT delorie DOT com, Brian Sturk Date: Sun, 14 Dec 1997 14:15:36 +0000 Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7BIT Subject: Re: Compiler error. "Invalid types" int[int] Cc: "Fernandes, Hilton" Precedence: bulk On Sat, 13 Dec 1997 00:59:02 -0500, Brian Sturk wrote > I'm trying to return a pointer to an array from a function and then > using it in my main program Hi! Please see the example below: --------------------------------------------------------- #include class TEST { public: int m_Array[10]; int* get_ptr (void) {return (m_Array);}; }; int main (void) { TEST t; int *ptr = t.get_ptr (); t.m_Array[0] = 2; cout << "*ptr == " << *ptr << endl; cout << "t.m_Array[0] == " << t.m_Array[0] << endl; return (0); } --------------------------------------------------------- It prints: --------------------------------------------------------- *ptr == 2 t.m_Array[0] == 2 --------------------------------------------------------- Pragmatic C++ programmers will disagree, but i think this is not good OOP practice. Regards, ++Hilton ------------------- Hilton Fernandes email: hgfernan AT usp DOT br www: http://www.lsi.usp.br/~hilton.html (inactive) M. Sc. Student of Parallel Distributed Applications at Escola Politecnica (Polytechic School) University of S. Paulo - Brazil