what does ->

Jan 14, 2017 at 7:06pm
I belive the title explains a lot. What does ->?
Jan 14, 2017 at 7:07pm
same as .
Jan 14, 2017 at 7:22pm
It's used to access members (variables or functions) of an object that a pointer is pointing to.

1
2
3
4
5
6
7
std::string  str = "ABC";
std::string* ptr = &str;

// Different ways of printing the first character of the string.
std::cout << str.front() << std::endl;
std::cout << ptr->front() << std::endl;
std::cout << (*ptr).front() << std::endl;
Last edited on Jan 14, 2017 at 7:23pm
Jan 14, 2017 at 7:25pm
See "Pointers to structures"
http://www.cplusplus.com/doc/tutorial/structures/

example pmovie->title
equivalent to (*pmovie).title
Topic archived. No new replies allowed.