forked from teseoch/CPP-Fall-2024
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path24-references1.cpp
44 lines (33 loc) · 846 Bytes
/
24-references1.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <iostream>
#include <string>
void print_vector(std::vector<double> &v)
{
for (auto val : v)
{
std::cout << val << " ";
}
std::cout << std::endl;
}
int main()
{
int x{100};
std::vector<double> vec{};
//push 1000000000000000000000000 values
print_vector(vec);
std::cout << "x is " << x << std::endl;
x = 6;
std::cout << "x is " << x << std::endl;
//Task: Create an alias "y" for the variable x,
// and use y to set the value of x to 1000
// int &y{x};
int &y = x;
y = 1000;
std::cout << "x is " << x << std::endl;
//Task: Create an alias "z" for the variable x
// using the auto keyword, then use z to
// set the value of x to 10000.
auto &z{x};
z = 10000;
std::cout << "x is " << x << std::endl;
return 0;
}