test ed studio LAB2
This commit is contained in:
parent
0b992089f3
commit
9b0c46bccc
12 changed files with 323 additions and 0 deletions
32
LAB2/test1.cpp
Normal file
32
LAB2/test1.cpp
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int somma(int &a, int &b) {
|
||||
return a + b;
|
||||
}
|
||||
|
||||
int &somma_ref(int &a, int &b) {
|
||||
return (a > b) ? a : b;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main(int argc, char const *argv[]) {
|
||||
|
||||
int pippo = 10;
|
||||
int paperino = 50;
|
||||
|
||||
int &referenza = (*somma_ref);
|
||||
|
||||
referenza(pippo,paperino);
|
||||
|
||||
printf("somma: %d\n", somma(pippo,paperino));
|
||||
printf("somma_ref: %d\n", referenza );
|
||||
|
||||
pippo = 100;
|
||||
printf("somma_ref AAA: %d\n", referenza );
|
||||
|
||||
// 100
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue