Xref: news-dnh.mv.net comp.os.msdos.djgpp:1158 Path: news-dnh.mv.net!mv!news.sprintlink.net!tank.news.pipex.net!pipex!news.mathworks.com!newshost.marcam.com!usc!math.ohio-state.edu!uwm.edu!msunews!harbinger.cc.monash.edu.au!lugb!harpo.riv.csu.edu.au!csu.edu.au!usenet From: Ian Tester <94024831 AT athene DOT mit DOT csu DOT edu DOT au> Newsgroups: comp.os.msdos.djgpp Subject: help with classes! Date: Tue, 25 Jul 1995 11:45:23 +1000 (EST) Organization: Charles Sturt University, NSW, Australia Lines: 36 Nntp-Posting-Host: athene.mit.csu.edu.au To: djgpp AT sun DOT soe DOT clarkson DOT edu Dj-Gateway: from newsgroup comp.os.msdos.djgpp hi, Sorry about this semi-djgpp content, but the c++ newsgroup is choka full of over 1500 messages, and I thought that my problem might be specific to djgpp. Anyway, I'm writting this 3D math library with classes for vectors, quaternions, and matrices. The vectors and quaternions work OK, but the matrix class doesn't. I'm pretty sure it's to do with the fact that the vec. and quat. classes don't have to allocate memory in their constructors. You see, in my matrix class, I have two ints which hold the number of rows and columns, and a 'float *' which will hold the array of elements. But to use it I have a constructor which takes the number of rows and columns to initialize it to, sets the two ints and allocates the memory with 'elements = new float[rows * cols]'. Is this right? Anyway, in a little test program, I declare a matrix with 'Matrix M;', and then latter initialize it with 'M = Matrix(3,3);'. Is this right? Should I declare it as a pointer ? i.e 'Matrix *M;' and 'M = new Matrix(3,3);' In the test program, it doesn't seem to set the two ints with the new size, so all other multiplications and stuff fail because its the wrong size. I would really like some help with this one. puh-lease! -------------------------------------------------------------------- Ian Tester 8)= Truth, Justice, and the GNU way still wishing for a pentium, or an Indy :-o, or... "A friend is someone who lets you help" - the fly, U2 -------------------------------------------------------------------- ERROR: caffeine not found, programmer halted