As for my knowledge, the object in a sentence is used to talk about the thing or person that the verb is done to or who receives the verb.
For example :
I put the orange cat into the garden.
With this sentence, it’s easy to identify the
objectwhich is the orange cat where the orange cat is the one who receives the verb.
But, how about this :
She was so unpopular that few people visited her in the hospital when she was ill.
I was confused and unsure which one is the object. Is it few people or her? or since the verb here is
visitedso the object in the sentence is her?
The second sentence is a complex one: it has one independent clause (with the subject ‘she’) and two dependent ones (with subjects ‘people’ and ‘she’). There’s a direct object ‘her‘ in the second clause (‘people visited her in the hospital’: visited whom?).
These explanations might be useful: