In C++, if an array has a size n, we can store upto n number of elements in the array. However, what will happen if we store less than n number of elements.
Data types in C++ specify the type of data that can be stored in a variable. They also determine the size of the memory allocated for the variable. Here are some additional details about the memory usage of data types in C++: • Char: A char variable is used to store a single character. It is typically represented as a single byte in memory. • Short: A short variable is used to store a small integer value. It is typically represented as two bytes in memory. • Int: An int variable is used to store a general-purpose integer value. It is typically represented as four bytes in memory. #30DaysOFCreative
Whitespace in C++: A line containing only whitespace, possibly with a comment, is known as a blank line, and C++ compiler totally ignores it. Whitespace is the term used in C++ to describe blanks, tabs, newline characters and comments. Whitespace separates one part of a statement from another and enables the compiler to identify where one element in a statement, such as int, ends and the next element begins. Statement 1 In the above statement there must be at least one whitespace character (usually a space) between int and age for the compiler to be able to distinguish them. Statement 2 In the above statement 2, no whitespace characters are necessary between fruit and =, or between = and apples, although you are free to include some if you wish for readability purpose.
Object-Oriented Programming in C++ 2) Data Members & Member Functions The attributes or data in the class are defined by the data members & the functions that work on these data members are called the member functions. Example: