summaryrefslogtreecommitdiff
path: root/member-access-test.cpp
blob: aeede896e661e5acf6f39070d3a136981df97bfb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <iostream>

/*
 *
 *
 *
 *
 */

int main () {

	std::string s1 = "a string";
	std::string *p = &s1;
	auto n1 = s1.size(); // Call size member function (method) on s1
	auto n2 = p->size(); // same thing but p is dereferenced and then call size member function (method) on s1
	auto n3 = (*p).size(); // same thing as above but without using '->' operator

	std::cout << n1 << " "
			  << n2 << " "
			  << n3 << " " << std::endl;
	return 0;
}