1

I don't understand why the & operator which mainly means "adress of" is there, I used this operator in C but in this code I don't understand it's purpose.

#ifndef _STUDENT_
#define _STUDENT_

struct Student {
    char* name;
    int mark;
};

void InitStudent(Student&);
void ShowStudent(Student);
void DeleteStudent(Student&);

#endif
Comrade57
  • 43
  • 1
  • 12
  • 2
    it marks "reference type" (semi-pointer) - something completely new (compared to C) in C++. Read some book / tutorial about C++ - C & C++ are completely different languages – Hcorg Jul 20 '15 at 15:45
  • A [good question](http://stackoverflow.com/questions/57483/what-are-the-differences-between-a-pointer-variable-and-a-reference-variable-in) to look at. – Soapy Jul 20 '15 at 15:49

1 Answers1

7

The & in Student& means that you are passing a (non-const) reference to a Student instance. It's not the C "address-of" operator.

Mr.C64
  • 41,637
  • 14
  • 86
  • 162
  • What does the byte pattern of a reference correspond to? For pointers, it is easy to understand that their byte pattern is simply the memory address of the pointee. Or, for an integer say 5, it is 00...0101. – The Vivandiere Jul 20 '15 at 15:48