-4

In this function declaration:

long * multiply(long ** numbers){

What do the * and ** mean? I'm somewhat of a beginner and haven't come across this before, so any explanation would be appreciated.

Sakura M.
  • 29
  • 1
  • 6
    Sounds like you could use a [good C++ book](http://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list) – NathanOliver Feb 06 '20 at 20:54
  • 1
    They're pointers and pointers to pointers. – Rietty Feb 06 '20 at 20:54
  • 1
    They are [pointers](https://en.cppreference.com/w/cpp/language/pointer). They are a very basic and fundamental type. However you are learning c++, through a book, a class or whatever else you might be using, they will eventually cover it. – François Andrieux Feb 06 '20 at 20:55

1 Answers1

2

Pointers:

Pointer declarator: the declaration S* D; declares D as a pointer to the type determined by decl-specifier-seq S.

Further:

A pointer that points to an object represents the address of the first byte in memory occupied by the object.

long* is a pointer to long. long** is a pointer to long*.

There is more you should read about and better stay away for some time from code that has a function declaration like this:

long * multiply(long ** numbers)

It is hard to think of a realistic scenario where multiplying numbers requires you to use a long**. Raw pointers are easy to use wrong and in modern C++ you rather only use them when you need to (which is actually quite rare).

463035818_is_not_an_ai
  • 109,796
  • 11
  • 89
  • 185