'char *test[]. What does it means this structure?
Example: // test.h
#define MAX 3
test.cpp
static char *movies[MAX] = {
"The Departed", "The Crow", "Hot Fuzz"};
//
Why not use Vector<char*>, or Vector<string*>, or an Array, or another data type? What benefits do i have over the other data types?
Let me preface this by saying that i'm coming from the Java world andi've been learning C++ for a few months.
Solution 1:[1]
You will not have to directly cast the pointer to another type.. if some functions only accept the char ptr vector then you will not have any conversion to do
Solution 2:[2]
What benefits do i have over the other data types?
One thing to notice if using std::vector is that it will be initialized dynamically at runtime while the static const char*[max] can be initialized at compile time. So it will save some(very little though) runtime.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Ayman TALHAOUI |
| Solution 2 | Anoop Rana |
