What is the lifetime of a C++ class member. For example, at which time will the std::fstream
of a Foo
object be released? When entering the destructor or when leaving the destructor? Is this defined in the C++ standard?
struct Foo
{
std::fstream mystream;
~Foo()
{
// wait for thread writing to mystream
}
};
string *name
, then name is the pointer that declared in one method, out of method name will be destroyed then how about the class's*name
? – Josettejosey