Differences between C and C++ - references
January 26, 2025, by Slobodan Dmitrovic
When moving from C to C++, references or reference types are one of the first novelties we encounter. References are aliases for existing objects in memory.
The general syntax is:
reference_type& name = initializer;
Passing function arguments by a reference
In C++, we can pass function arguments by
- by reference
- by const-reference
Function arguments in C and C++
In C, we can pass arguments by value:
void myfn(int arg);
And by a pointer
void myfn(int* p);
In C++, we mainly pass arguments by value:
void myfn(int arg);
and by a const-reference:
void myfn(const MyClass& arg);
Built-in types are passed by value and complex types (classes) are usually passed by const-reference. Passing by const-reference avoids creating costly copies and makes the object a read-only object.
Are references pointers?
References are not pointers. They are a different kind of type. They are simply aliases, another name for something that is already there in memory. In C, we can declare a pointer-type function parameter and pass in the address of an existing object. In C++, an equivalent would be to declare a reference-type function parameter and pass in the object's name.

We also have a dedicated training course called "C++ for C Developers." For more info, contact us at contact@cppsrc.com.
Download the Brochure