(10%) Assume that a file "fname.txt" was generated in the previous question. Determine
whether the following code has syntax errors or not. If
it is correct, predict its output. If it is incorrect, point out
the mistake(s).
// Size of an object
#include <iostream>
#include <cstring>
class CMessage
{
public:
char* str;
CMessage(char* s)
{
str = new char[strlen(s) + 1];
strcpy(str, s);
}
~CMessage()
{
delete str;
str = NULL;
}
};
int main()
{
CMessage city("Taipei");
std::cout << sizeof(city) << std::endl;
// Assume that you are running this program on a 32-bit operating system
std::cout << strlen(city.str) << std::endl;
return 0;
}