Awesome q2a theme
0 votes

Why option A is wrong?



in Programming by (15 points) | 35 views

1 Answer

+4 votes
Best answer
$->$ operator is used to access any member of an object using the pointer of that object and $.$ (dot) operator is used to access any member of an object from using the object itself. For example, if $x$ is member of object $o$, then $o.x$ is same as $(\& o)\ – >x$ and both ways are valid to access the member $x$ of object $o$, but $(\&o).x$ is invalid because $(\&o)$ is a pointer, as well as $o\ ->x$ is also invalid because $o$ is not a pointer.

For the given definition of $struct\ plist$, member $pt$ is of type $P$ and not $P\ *$, hence to access any member of $pt$ , dot operator will be used. Hence $head\ -> P.X$ is valid and  $head\ -> P\ ->X$ is invalid.
by (855 points)
selected by
Thanks brother for clearing the doubt.
Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
Welcome to GATE CSE Doubts, where you can ask questions and receive answers from other members of the community.
8,446 questions
2,720 answers
95,468 users