0

I have a function that looks something like

foo(object& obj) {

}

inside this function I need to call another function like this:

foo(object& obj) {
    bar(pointer to obj);
}

the bar function takes a pointer to the object as an argument. Could some help I can do convert from non pointer to pointer?

user3312064
  • 33
  • 1
  • 2
  • 1
    -1 because it's ridiculous to ask on SO about the basicest basics of the language. That's what C++ books are for. – Matteo Italia Jul 03 '14 at 16:55
  • 2
    This is indeed a very basic programming question, but a legitimate one, and reasonably well formulated. There are no requirements on SO about the "level" of the question. I'm upvoting to put it back in the queue. – Kirk Roybal Jul 03 '14 at 17:17

3 Answers3

5

That what & is for, the "address of" operator.

bar(&obj);
David Schwartz
  • 179,497
  • 17
  • 214
  • 278
0

Call bar with the address of obj:

bar(&obj);

edtheprogrammerguy
  • 5,957
  • 6
  • 28
  • 47
0

Call as follows

bar(&obj);

Sujith Gunawardhane
  • 1,251
  • 1
  • 10
  • 24