Search code examples
c++arrow-functionsgithub-codereviews

How to understand code like this in c++ [request->headers().Method()->value().getStringView())]


I am suppose to reduce it down to [request->headers().getMethodValue())].

I am fairly new to C++. Can someone please tell me how to understand this type of code? There are multiple . operator and -> operator. I loose track of the classes and others.

It's a little overwhelming.


Solution

  • The . operator is used to access stuff inside the object (functions, variables etc.) the -> operator is just a . operator but for pointers. In your case you call request's headers function that returns an object. For that object then you call getMethodValue function.