A vector is a dynamic array with automatically handled storage. The elements in a vector can be accessed just as efficiently as those in an array with the advantage being that vectors can dynamically change in size.
In terms of storage the vector data is (usually) placed in dynamically allocated memory thus requiring some minor overhead; conversely
std::array use automatic storage relative to the declared location and thus do not have any overhead.
Returning several values from a function
There are many situations where it is useful to return several values from a function: for example, if you want to input an item and return the price and number in stock, this functionality could be useful. There are many ways to do this in C++, and most involve the STL. However, if you wish to avoid the STL for some reason, there are still several ways to do this, including
What is undefined behavior (UB)? According to the ISO C++ Standard (§1.3.24, N4296), it is "behavior for which this International Standard imposes no requirements."
This means that when a program encounters UB, it is allowed to do whatever it wants. This often means a crash, but it may simply do nothing, make demons fly out of your nose, or even appear to work properly!
Needless to say, you should avoid writing code that invokes UB.
Compiling and Building
Programs written in C++ need to be compiled before they can be run. There is a large variety of compilers available depending on your operating system.
Strings are objects that represent sequences of characters. The standard
string class provides a simple, safe and versatile alternative to using explicit arrays of
chars when dealing with text and other sequences of characters. The C++
string class is part of the
std namespace and was standardized in 1998.
C++ file I/O is done via streams. The key abstractions are:
std::istream for reading text.
std::ostream for writing text.
std::streambuf for reading or writing characters.
Formatted input uses
Formatted output uses
std::locale, e.g., for details of the formatting and for translation between external encodings and the internal encoding.
More on streams: http://stackoverflow.com/documentation/c%2b%2b/7660/iostream-library