for input please look at the for loop in the operator overloading section
It is showing segmentation fault when i give odd number of input
@Deepanshu_garg
Line No. 93.
Reverse the check condition.
while(fast!=NULL && fast->next!=NULL)
fast!=NULL should be checked first.
Does it make any difference anyway it will check both the conditions
@Deepanshu_garg
It does. Try making this change and your error will get resolved.
You are right that it will check both the conditions but what matters is that which one does it check fast. Consider the case when fast pointer is at NULL , if it first checks the condition for fast->next , it will get an error as NULL does not have a next .
However if we change it to check whether fast is not equal to NULL first as I have suggested , the first condition will return false and since we are taking the and (&&) here , if the first condition returns false , it will not bother to check the second part hence preventing the error.
The second part will only get evaluated if the first one returns true.