I'm coding c++11. In a class A, I have a member variable "member" which is defined as
vector<OtherClass> member; // A's member variable
I would like to serialize A ( so I want to all the data type in OtherClass contained in the vector ) into file in binary format so I defined a function write as follows.
void A::write(ostream& os){ // A's function for outputting A
os.write(reinterpret_cast<const char*>( &(member.size()) ), sizeof(member.size()));
}
But compiler said lvalue required as unary '&' operand.
How can I fix it without creating a temporary object such as long size=member.size() in the write function?