- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to pass an array by reference in C++
If we pass the address of an array while calling a function, then this is called function call by reference. The function declaration should have a pointer as a parameter to receive the passed address, when we pass an address as an argument.
Example Code
#include <iostream> using namespace std; void show( int *num) { cout<<*num; } int main() { int a[] = {3,2,1,6,7,4,5,0,10,8}; for (int i=0; i<10; i++) { show (&a[i]); } return 0; }
Output
32167450108
- Related Articles
- Pass an integer by reference in Java
- Differences between pass by value and pass by reference in C++
- Pass by reference vs Pass by Value in java
- How to pass arguments by reference in Python function?
- Pass an array by value in C
- What is pass by reference in C language?
- Describe pass by value and pass by reference in JavaScript?
- Is java pass by reference or pass by value?
- How do we pass parameters by reference in a C# method?
- How to pass arguments by reference in a Python function?
- Which one is better in between pass by value or pass by reference in C++?
- What is Pass By Reference and Pass By Value in PHP?
- Why do we pass a Pointer by Reference in C++?
- Pass by reference vs value in Python
- Is JavaScript a pass-by-reference or pass-by-value language?

Advertisements