In line 2 of your .cpp did you want to create a pointer array on purpose? Because you don't have any references to memory or pointers with the rest of your code.
Ya, so the point of the project is to learn about dynamic memory allocation so we're not allowed to use the array or vector class. In my header file I also have public variables:
[code]
double **array;
uint rows;
uint cols;
I made a void function that prints the matrix, is very similar to your constructor, and it works. The error might be somewhere else. The only difference is that instead of uint, I used unsigned int. Check your uint object.
Would the error possibly lie with the compiler you're using? Like I haven't heard the greatest things about Turbo C++ and stuff like that. I won't be able to help you out if the issue originates there but at least we can get some info to work with.
It's just a basic g++ compiler on linux. I really doubt that would be the issue, I'm very inexperienced in C++ so I almost guarantee it's an error on my part.
Post both your .cpp and .h? If there's a definitive error there, we'll be able to tell right away. Also what's the exact error message you're getting from the compiler? Might point us in the right direction as well.
The './' doesn't matter since it's in the same folder as that's open in the terminal. The './' just denotes that you can navigate to different folders and also compile the exe to different folders.
Is free() your destructor? You should post the code. The destructor for a class is called every time an object goes out of scope or when delete[] is applied to a pointer that points to an object class. When you do dynamic allocation, always implement your own destructor, otherwise you have memory leak.
You have to use your destructor to free the memory allocated in your dynamic array before deleting the pointer. You need to do this every time you have a dynamically allocated variable in your class. The default destructor will just delete your pointer and not the actual content the pointer points to. If this happens, all access to your data is lost, meaning it cannot be accessed or deleted. Hence we call this a memory leak.
We're not seeing enough code to be of help yet, but I noticed you stated two members, cols and rows, in the matrix class, but you're also using those names as parameters in the constructor.
Consider separating those to avoid confusion if that's the case.