Why is my classmate guy only talking to me when he is not around his friends?

He only talks and flirts with me when we are alone and today he smiled at me when laughing with his friends like he was seeking approval of his joke.
Why is my classmate guy only talking to me when he is not around his friends?
Post Opinion