-1

For example static Car* getCar(int id), why is there a pointer here, and what does it do?

  • 4
    The return type of the function is `Car*` meaning we're returning a pointer to an object of type `Car`. This is explained in any beginner level [good C++ book](https://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list) – Anoop Rana May 24 '22 at 11:52
  • Can you provide an example? – Akatsyki May 24 '22 at 11:54
  • 3
    The function doesn't _point to a class_. The function returns a pointer to an instance of that class. (If this doesn't make sense to you - sorry, please have a look into a [C++ book](https://stackoverflow.com/a/388282/7478597).) – Scheff's Cat May 24 '22 at 11:54
  • @Akatsyki See [demo example](https://onlinegdb.com/3gCL4DnbX). – Anoop Rana May 24 '22 at 11:58
  • Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. – Community May 24 '22 at 15:56

0 Answers0