Skip to content

Mistake in the article about references #67

@Kostik654

Description

@Kostik654

Link:
https://github.com/devtut/generate/blob/master/docs/cpp/references.md

I quote:

void func (int &fParam ) {
   cout<<"Address inside function => "<<fParam<<endl;
}

int main() {
    int i = 10;
    cout<<"Address inside Main => "<<&i<<endl;    

    func(i);

    return 0;
}

In this example also, both cout will print the same address.

Output:

Address inside Main => 0x14561ffb1c  
Address inside function => 10 

In this case, the function func outputs the value of the variable, not its address. Checked by the compiler.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions