dynamic-memory-allocation
Allocating struct with variable length array member
I know I can do new char[n] to create an array of n chars. This works even when n is not a compile time constant.[详细]
2023-04-10 03:32 分类:问答Dynamically set array access pattern in C
I would like to do something like this in C(99): int n = compute_size_of_matrices(); int T = compute_number_of_matrices();[详细]
2023-04-04 18:56 分类:问答Memory allocation for variable declared in class
As Value type variable allocates memory in Stack whereas Reference type allocates it in Heap. So how the memory allocated when a value type variable (e.g. int i = 4;) is declared in the reference type[详细]
2023-04-03 05:13 分类:问答C++ dynamic (multi-stage) 3D vector instantiation and element assignment
Okay, so I need to create a 3D data-structure at run-time, I decided to use std::vector, the problem is as follows: I know the dimension of the 1st dimension at instantiation time (when I create the o[详细]
2023-03-24 01:03 分类:问答Malloc function (dynamic memory allocation) resulting in an error when it is used globally
#include<stdio.h> #include<string.h> char *y; y=(char *)malloc(40); // gives an error here int main()[详细]
2023-03-21 19:56 分类:问答Vectors, Pointers, Rabbits and reclaiming memory revisited
Brief Description In a previous post I asked around about a problem with dangling pointers. I understood that I\'m advised to use Boost and I will rewrite my program as soon I fully got the basics ab[详细]
2023-03-18 17:58 分类:问答difference between two array declaration methods c++
These of 2 of the probably many ways of declaring arrays (and allocating memory for them) in c++ 1. int a[3];[详细]
2023-03-18 09:45 分类:问答Alignment of Heap Arrays in C and C++ to Ease Compiler (GCC) Vectorization
I\'m currently cooking up a wrapper container template class for std::vector that automatically creates a multi-resolution pyramid of the elements in its std::vector.[详细]
2023-03-18 05:11 分类:问答Getting object properties from a pointer stored in a vector
Compact description I\'m having a problem to find out what\'s wrong, for some obscure reason the properties in an object for which I stored the pointer in a vector seem to be changed.[详细]
2023-03-17 19:02 分类:问答Mixing operator new[] and placement new with ordinary delete[]
Just out of curiosity, is the following legal? X* p = static_cast<X*>(operator new[](3 * sizeof(X)));[详细]
2023-03-16 03:50 分类:问答