Rozdíly

Zde můžete vidět rozdíly mezi vybranou verzí a aktuální verzí dané stránky.

Odkaz na výstup diff

public:pb161_passreference [2018/02/24 19:10] (aktuální)
Řádek 1: Řádek 1:
 +<code c reference.cpp>​
 +#include <​iostream>​
 +/*
 +    TODO:
 +    1. Correct declaration and implementation of addNumbersByPointers function
 +       so code will compile and code in main() will output values "a value: 5" and "b value: 3".
 +       Do NOT change code in main()
 +    2. Create function addNumbersByReference so code in main() will compile and output "a value: 5" and "b value: 3".
 +       (Only change in main() is removing addNumbersByPointers() call and adding addNumbersByReference() call)
 +    3. Use const where suitable to prevent unwanted changes
  
 +    NOTE: Try to understand compiler warning and errors
 +*/
 +
 +void addNumbersByPointers(int A, int B) {
 +    A = A + B;
 +}
 +
 +int main() {
 +    int a = 2;
 +    int b = 3;
 +
 +    addNumbersByPointers(&​a,​ &b);
 +    std::cout << "a value: " << a << std::endl;
 +    std::cout << "b value: " << b << std::endl;
 +
 +    return 0;
 +}
 +</​code>​
QR Code
QR Code public:pb161_passreference (generated for current page)