Different ways to deallocate an array – c++

new type requires deletenew type[size] requires delete []Using one instead of the other is wrong. Btw you should not use such raw pointers like this unless you have a very good reason. Use std::vector or std::array instead. And 2D MxN arrays should generally be linearised into 1D M*N arrays, also using these containers.

C++ calling base class constructors

The short answer for this is, “because that’s what the C++ standard specifies”. Note that you can always specify a constructor that’s different from the default, like so: The default constructor of the base class is called only if you don’t specify which one to call.

Multiple inputs on one line

Yes, you can input multiple items from cin, using exactly the syntax you describe. The result is essentially identical to: This is due to a technique called “operator chaining”. Each call to operator>>(istream&, T) (where T is some arbitrary type) returns a reference to its first argument. So cin >> a returns cin, which can … Read more

How can I get a file’s size in C++?

See http://www.cplusplus.com/doc/tutorial/files/ for more information on files in C++. edit: this answer is not correct since tellg() does not necessarily return the right value. See http://stackoverflow.com/a/22986486/1835769

Using cin to input a single letter into a char

You are not inputting or outputting the characters correctly. char letter[2] is an array of 2 characters, not a single character. You want char letter. Further, you are outputting letter[2], which is the third element of an array that only has two values (indexing in C++ starts from 0; the first element is letter[0] and … Read more

Static vs dynamic type checking in C++

Static type checking means that type checking occurs at compile time. No type information is used at runtime in that case. Dynamic type checking occurs when type information is used at runtime. C++ uses a mechanism called RTTI (runtime type information) to implement this. The most common example where RTTI is used is the dynamic_cast … Read more