Pass Object As Function Arguments in C++

We can pass objects as arguments in member or non member functions. They can be passed either by value or reference. Pass by value creates another copy of the particular object which is deleted after the function is ended. Pass by reference means that we are passing the same object as a reference so if we do any changes in the object then it will remain permanently.

Here is an example of passing objects in function arguments.

Output:

In the above code, we are passing the objects in the avgmarks() function, using the information provided by both the objects the average mark is calculated.

I hope you have understood this blog. Please do comment below if you are still facing any difficulties with this topic.

Leave a Comment

Your email address will not be published. Required fields are marked *