I am looking into the pointers and I came up with code like that
class b
{
}
class d
{
}
d* a = 0;
b *t = new b();
*t = * ( b* )a;
What does this declaration mean?
What value does t have?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
twill still be pointing to the object created withnew b();.*t =changes the value of whattpoints to, nottitself.Your last line contains undefined behavior as you’re derefenrencing a null pointer. Also, your cast is actually a
reinterpret_castin disguise, which is something you shouldn’t do.