-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpractice9.cpp
56 lines (41 loc) · 1.1 KB
/
practice9.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
45
46
47
48
49
50
51
52
53
54
55
56
#include <iostream>
#include <memory>
#include <string>
using namespace std;
struct Student
{
string fName;
string lName;
string getFullName();
};
string Student::getFullName()
{
return fName + " " + lName;
}
int main()
{
unique_ptr<int> pointer = make_unique<int>(25);
Student student;
student.fName = "Aryan";
student.lName = "Jain";
string fullName = student.getFullName();
cout << "Full Name: " << fullName << endl;
// Arrays
int arr[] = {11, 12, 13, 14, 15, 16};
int arrSize = sizeof(arr) / sizeof(int);
cout << "sizeof(arr): " << sizeof(arr) << endl;
cout << "sizeof(int) " << sizeof(int) << endl;
cout << "sizeof(arr[0])" << sizeof(arr[0]) << endl;
cout << "Arr size: " << arrSize << endl;
cout << "\n\nAddresses : " << endl;
for (int i = 0; i < arrSize; i++)
{
cout << "arr + " << i << " : " << (arr + i) << endl; // consecutive memory addresses.
}
cout << "\n\nValues : " << endl;
for (int i = 0; i < arrSize; i++)
{
cout << "*(arr + " << i << ") : " << *(arr + i) << endl;
}
return 1;
}