#include <iostream>
#include <string>
#include <vector>
using namespace std;
//
// YOUR NAME: EVAN LYTTLE
//
int main(void)
{
// Fundamental C++ types
// There are several fundamental types in C++ including char, short, int
// long, unsigned, float, double, long double, boolean (bool) and void.
// We can use the sizeof() function to determine how much memory is
// allocated for these various data types to better explore the concepts
// of Chapter 6 and understand how and when memory is allocated (static vs.
// dynamic). Following the example given for char, fill in the code for the
// remaining fundamental types (if possible).
cout <<"Fundamental Types\n";
cout <<" Type " << "Size \n";
cout <<" char: " << sizeof(char) << " bytes.\n";
cout <<" int: " << sizeof(int) << " bytes.\n";
cout <<" short: " << sizeof(short) << " bytes.\n";
cout <<" long: " << sizeof(long) << " bytes.\n";
cout <<" float: " << sizeof(float) << " bytes.\n";
cout <<" unsigned: " << sizeof(unsigned) << " bytes.\n";
cout <<" double: " << sizeof(double) << " bytes.\n";
cout <<" long double: " << sizeof(long double) << " bytes.\n";
cout <<" bool: " << sizeof(bool) << " bytes.\n";
cout <<" void: " << sizeof(void) << " bytes.\n";
// C++ Pointers
// C++ allows for pointers to, among others, char, long and void data types.
// We can again use the sizeof() function to determine how much memory is
// allocated for these various data types to better explore the concepts
// of Chapter 6 and understand how and when memory is allocated (static vs.
// dynamic). As you did above, fill in the code to determine the memory size
// allocated for these three pointer types.
cout <<"\nPointers\n";
cout <<" Type " << "Size \n";
// Example for an integer pointer
int i = 455;
int *intPointer = &i;
cout <<" int pointer: " << sizeof(intPointer) << " bytes.\n";
//char pointed
char c = 'a';
char *charPointer = &c;
cout <<" char pointer: " << sizeof(charPointer) << " bytes.\n";
//long pointer
long l = 455;
long *longPointer = &l;
cout <<" long pointer: " << sizeof(longPointer) << " bytes.\n";
//void pointer
void *voidPointer = &i;
cout <<" void pointer: " << sizeof(intPointer) << " bytes.\n";
// C++ Strings
// Using the <string> library, we can explore the memory sizes allocated for
// C++ strings using the sizeof() function. You should fill in code below to
// experiment with how C++ allocates memory for various strings. For example,
// you may want to compare setting the value of a string with "josh" and
// getting its sizeof() compared with sizeof("josh"). You should also provide
// code to determine when the memory size of the string is determined and
// whether it can change or not.
cout <<"\nStrings\n";
cout <<" Type " << "Size \n";
string s;
cout <<" string s before joshified: " << sizeof(s) << " bytes.\n";
s = "josh";
cout <<" string s after josh: " << sizeof(s) << " bytes.\n";
cout <<" string of direct sizeof(josh): " << sizeof("josh") << " bytes.\n";
s = "joshua";
cout <<" string s after made into joshua: " << sizeof(s) << " bytes.\n";
s = "joshuaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
cout <<" string s after made much longer: " << sizeof(s) << " bytes.\n";
// C++ Enumerations
cout <<"\nEnumerations\n";
cout <<" Type " << "Size \n";
enum weekday {monday = 1, tuesday = 2, wednesday = 3, thursday = 4, friday = 5, saturday = 6, sunday = 7};
cout <<" enums: " << sizeof(weekday) << " bytes.\n";
enum january {january=1};
cout <<" enum2: " << sizeof(january) << " bytes.\n";
// C++ Arrays
// In C++, you can declare arrays by providing a name and a size of the array.
// The sizeof() function will again provide the amount of memory allocated for
// the array. Experiment with different array sizes and types to see how much memory
// is allocated, and when it is allocated (declaration vs. instantiation).
cout <<"\nArrays\n";
cout <<" Type " << "Size \n";
int intArray[1];
cout <<" int array: " << sizeof(intArray) << " bytes.\n";
long longArray[1];
cout <<" long array: " << sizeof(longArray) << " bytes.\n";
double doubleArray[1];
cout <<" double array: " << sizeof(doubleArray) << " bytes.\n";
char charArray[1];
cout <<" char array: " << sizeof(charArray) << " bytes.\n";
int intierArray[100000];
cout <<" big int array: " << sizeof(intierArray) << " bytes.\n";
// C++ Standard Library Vectors
// In C++, you can declare a vector as follows: vector<char> v(10); and similarly
// determine its size using the sizeof() function. Experiment with different
// vector sizes and types so that you can compare the differences bewteen C++
// arrays and vectors.
cout <<"\nVectors\n";
cout <<" Type " << "Size \n";
vector<int> intVec(1);
cout << " int vector: " << sizeof(intVec) << " bytes.\n";
vector<long> longVec(1);
cout << " long vector: " << sizeof(longVec) << " bytes.\n";
vector<double> doubleVec(1);
cout << " double vector: " << sizeof(doubleVec) << " bytes.\n";
vector<char> charVec(1);
cout << " char vector: " << sizeof(charVec) << " bytes.\n";
vector<int> iVec(100000);
cout << " intier vector: " << sizeof(iVec) << " bytes.\n";
}