Subj : Returning structures from template classes To : borland.public.cpp.borlandcpp From : DJV Date : Sat Oct 01 2005 09:38 pm I am trying to return both a matrix and a simple unsigned integer from a matrix class in a header file to indicate whether a matrix has been successfully inverted. It occurred to me to use a pointer to a structure, but two problems developed. 1. In the "main()" body of the calling routine that calls the matrix class function, I do not seem to be able to create a matrix object as part of a structure. I can create a matrix object (or several of them if I wish) in the same "main()" body, but only by themselves,not as part of a structure. I can not assign the matrix size in the structure. I can declare a Matrix q, but not a Matrix q(3,3), as I can outside of the structure. 2. This is a template class, so I do not know the type of data contained in the matrix (complex, int, or double) that is being sent to the template class function. If I could declare this structure as a template in the template class, I could simply return the structure. 3. I considered creating a pointer to a structure created in the template function after the template data type is received by the function, but I run into problems in the main body of the calling program because the matrix class doesn't seem to work if I incorporate it into a structure, and because I am not sure how to set the pointer to a structure returned by the matrix class equal to a pointer, presumably, to a structure of the same size and containing the same elements in the main calling routine. Any help would be appreciated. I realize this may be a bit vague. My goal is to not return a matrix that is partially inverted but can not be completely inverted, due to the potential to cause the user errors. I'm using Borland C++ 4.51 to develop the matrix class in a header file. I have this working if I simply return a matrix. It seems odd that I can get the template class to work for sending and receiving matrices, but am having trouble getting these matrices incorporated into structures that I can both send and receive from a template class routine. Thanks. .