0

i used integer but i am asking for too much big datas. Will memory usage be the same ? Or speed ?

void func1(int *a)
{

}

void func2(int &a)
{

}  

int main()
{
  int a;


  func1(&a); // pointer way
  func2(a); // what is it ? is this also pointer way ?
}
luffy
  • 23
  • 4
  • I suggest you read a good book, it'll be explained. – Rosme Jan 29 '20 at 20:45
  • 3
    Does this answer your question? [What are the differences between a pointer variable and a reference variable in C++?](https://stackoverflow.com/questions/57483/what-are-the-differences-between-a-pointer-variable-and-a-reference-variable-in) – Rosme Jan 29 '20 at 20:45
  • 2
    Speaking of good [books](https://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list). – Zheng Qu Jan 29 '20 at 20:45
  • A quick answer to your question: yes, both versions perform a *pass-by-reference*. But please consider reading a book, you'll save a ton of time (and frustration). – rustyx Jan 29 '20 at 20:49
  • 1
    What is the concern for speed or memory size? Is your application running on a memory restricted (embedded systems) platform? Is your application expected to make real-time events? If not any of these, concern yourself with developing a quality application that is robust. – Thomas Matthews Jan 29 '20 at 21:25

0 Answers0