dynamic-allocation
How do I allocate memory by using new in C++?
I have following s开发者_C百科tatic declaration of memory: void* array[5000]; How I can allocate the same memory using operator new in C++?void **array = new void*[5000];[详细]
2023-04-13 09:09 分类:问答Using 'new' keyword with struct in c++
#include \"PQueue.h\" struct arcT; struct coordT { double x, y; }; struct nodeT { string na开发者_StackOverflow社区me;[详细]
2023-04-12 20:11 分类:问答How to make it so the user can't delete a dynamic array?
In writing a response, I wrote some code that challenged my assumptions on how const pointers work. I had assumed const pointers could not be deleted by the delete function, but as you\'ll see from th[详细]
2023-04-12 13:51 分类:问答Deleting a doublepointer (matrix)
I am solving a quantum-mech problem which requires me to find some eigenvalues by manipulating some matrices. The specifics of this problem is not relevant, I just need help with the c++ problem, I am[详细]
2023-04-07 22:17 分类:问答"dynamic constructor" in c++
i am new to classes in C++ and i need to create a class \"Plot\" which has a method that reads in data from a file and creates a 3d grid.[详细]
2023-04-07 19:13 分类:问答Dynamic memory allocation of objects in C++
I\'m trying to dynamically allocate (it\'s not so dynamic as it is right now, but eventually it will be) memory for objects in a very simple C++ program. I\'m new to classes and have only recently sta[详细]
2023-03-22 10:37 分类:问答memory allocation in Stack and Heap
This may seem like a very basic question, but its been in my head so: When we allocate a local variable, it goes into stack. Similarly dynamic allocation cause the variable to go on heap. Now, my que[详细]
2023-03-22 07:20 分类:问答Calloc causing segmentation fault
Here is my code: #include <stdio.h> #include <stdlib.h> int main(){ int n=10; char *s= calloc(2,sizeof(char));[详细]
2023-03-22 04:22 分类:问答Declaring global variable (array) inside a function in C
I need to declare a global two-dimensional array in C. The size of the array is determined by the width and height of a given picture.[详细]
2023-03-22 02:04 分类:问答Freeing a dynamically allocated 2D structure
I\'ve dynamically allocated a structure, conceptually very similar to a matrix, to hold a set of strings. I\'ve encountered a problem while trying to free the memory. My code looks like this:[详细]
2023-03-22 00:43 分类:问答