friend , i have a problem with my code when try to write the content of object to the file i use code block 17 .
#include <iostream>
#include<string>
#include <fstream>
using namespace std;
class human{
public:
string name;
string country;
human(string a,string l )
{
name=a;
country=l;
}
};
// Driver Code
int main()
{
human a("Ronaldo","Portugal");
ofstream file;
file.open("last.txt");
file.write((char*)&a,sizeof(a));
return 0;
}
the output like this in the file
€n Ronaldo ùn~v4} کn Portugal dv
there are some weird symbols