next up previous
Next: Dynamische Allokation Up: Pointer Puzzles Previous: Call by Reference I

Call by Reference II (nur C++)

void func(const int &locint)
{
    cout << locint << endl;
    locint=7;
}

main()
{
    int i=3;
    func(i);
    cout << i << endl;
}

Programm ist falsch, da die Zuweisung ungueltig ist.
Compiler:
assignment of read-only reference `const int & locint'


next up previous
Next: Dynamische Allokation Up: Pointer Puzzles Previous: Call by Reference I

© 1997 Gottfried Rudorfer, C++-AG, Lehrveranstaltungen, Abteilung für Angewandte Informatik, Wirtschaftsuniversität Wien, 3/19/1998