what does ->

I belive the title explains a lot. What does ->?
same as .
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
See "Pointers to structures"
http://www.cplusplus.com/doc/tutorial/structures/

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