Well, you can make a pointer to an array like this:
int (*arr)[20];
But keep in mind, you are creating just a pointer (to an array) there, not the actual array. So, there is nothing to print out.
I would suggest that you use vectors instead of arrays, like:
vector<int> arr(20);
vector<int>* arrP = &arr;
etc...
Can someone explain to me why does every BEGINNER here use C-style arrays? I mean, do they all have time machines and are attending some 70's C programming course? And, no wonder, then they runt into trouble. std::vector should be highly preferred over arrays.
Can someone explain to me why does every BEGINNER here use C-style arrays?
Sure, because you need to know arrays to be a competent c++ programmer. It annoys me when people tell beginners not to learn arrays. Arrays are an important part of c++. Even if you never use them yourself, you will undoubtedly encounter them in older code. I use several libraries that require the use of arrays, not to mention that you will encounter c code at some point.
Because most of the people teaching couldn't write good code to save their hide, and learned C++ before there were standards most likely.
I'm not an academic so I don't have a position to defend. But I think the above comment is drawing a very very long bow.
Even the god of C++, the man himself, devotes substantial time in the introductions to arrays and then later goes on to talk about the limitation and pitfalls along with the niceties of later developments and alternative options.
I always wonder whether the array-police wouldn't be better off sticking with QBasic and not advancing their learning at all.
I think/know there's a difference with a university education and getting your education at a game-cutter school.
- The people who teach arrays-first actually have a rationalization for it. (of course, I would opine that the ratonalization is flawed, but that is another issue...). I mean, it is not because they are lacking experiecne with vectors, or they are afraid of vectors, or they are used to arrays, or they just don't want to modernize and update their old materials.
I mean, are their reasons at least somewhat legit, or are they just an excuse? Because I can't think of a good reason to support arrays-first. Ok, perhaps if an instructor is a believer in low-level programming and low-level optimizations, then I would believe that he is not just mocking me. (but I would still think that he is a bad instructor).
- Those people are actually in majority, as it seems
- You are undecided on the issue yourself, and you are wondering if it has any substantial impact in pratcice.
I'm also wondering whether, if you were teaching C++, would you decide to go arrays-first or vectors-first?
Right, you are mocking, and that is a kind of rude.
Tell me, what do you think, is a decimal number system better than Roman numerals? And what are the arguments for and against? Are there any arguments for one or the other at all?
And is it irrelevant whether we use Roman or decimal number system? Is world a better place because of good or bad decisions that humanity made?
Edit:especially considering one of your previous comments about bringing students to tears.
Are there any arguments for one or the other at all?
If you surf around these threads for a short while Inspector Kevvy, you'll see numerous examples of where C++ exercises address the two systems and the task of converting between the two in great detail.
woah, that escilated quickly. Also, who says i'm a beginner? I've been programming for 6 years... I'm just digging deeper into C++ and trying to learn even more. I already know how to use vectors as well.