How do I check if a class is null or not in C++? Suppose I have class Line:
Line line[1000];
if (line[0] == NULL)
cout << "NULL";
else
cout << "NOT NULL";
I get this error message:
no match for ‘operator=’ in ‘line[i] = 0’
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.
The code
creates 1000 Line objects and stores them in the line array. The test against NULL makes no sense. You could define
In that case you need to initialize the array and your test would work.