Hi there,
You can't daclare something like:
int x;
cin >> x;
int a[x];
It won't compile because x is unknown in the time of compilation. Values in brackets while declaring arrays have to be daclered before compilation.
U can try to declare 2-dimension array using new. Problem is that in C++ u can't declare 2-dimensional array directly.
Example u can remake for...
User Profile
Collapse
-
Collection is a pointer to dynamic array of pointers to Objects - Items. I need it that way because i want to place all objects on the heap (not in the operational memory) and i want to be able to reallocate dynamically size of a table where i hold pointers to objects(collect ion).
In constructor I'm declaring that variable for the first time - i forgot to copy/paste it.
Code:t_Item::t_Item() { liczba_item=0;
Leave a comment:
-
-
-
Dynamic memory allocation - memory corruption error
Hi there,
I have a problem with dynamic memory allocation. I know that it would have been easier to use vectors methods, but i want to know what i do here wrong.
This is one of my methods in t_Item class - I use it to store Item Objects (which are classes too).
xxxxxxxxxxxxxxx xxxxxxxxxxxxxxx xxx
class t_Item {
public:
t_Item();
Allocate_Item() ;
private:...
No activity results to display
Show More
Leave a comment: