Linked list vs. dynamic array for implementing a stack

There are many tradeoffs involved here and I don’t think that there’s a “correct” answer to this question. If you implement the stack using a linked list with a tail pointer, then the worst-case runtime to push, pop, or peek is O(1). However, each element will have some extra overhead associated with it (namely, the … Read more

Why doesn’t C++ support dynamic arrays on the stack? [closed]

I think, it’s because C++ provides superior solutions: std::vector<T> and std::array<T,N> (C++11); though the latter is not dynamic as such but it’s superior to raw arrays. You can always know the size, no matter which function you pass the vector or array. Since C cannot provide these solutions, C99 came up with Variable Length Array … Read more

How do I declare an array when I don’t know the length until run time?

As of Delphi 4, Delphi supports dynamic arrays. You can modify their sizes at run time and they will retain the data you stored in other elements at the old size. They can hold elements of any homogeneous type, including records and other arrays. You can declare a dynamic array the same as you declare … Read more

Why is it undefined behavior to delete[] an array of derived objects via a base pointer?

Base* p = new Base[n] creates an n-sized array of Base elements, of which p then points to the first element. Base* p = new Derived[n] however, creates an n-sized array of Derived elements. p then points to the Base subobject of the first element. p does not however refer to the first element of … Read more

Why both runtime-sized arrays and std::dynarray in C++14?

N3639 proposes to add local runtime-sized arrays with automatic storage duration to C++. N2648 says that in keeping with C++ practice, std::dynarrays are usable with more than just automatic variables. But to take advantage of the efficiency stack allocation, we wish to make dynarray optimizable when used as an automatic variable. In short, C11 style … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)