Check out example codes for "function in struct c++". It will help you in understanding the concepts better.

Code Example 1

struct foo {
  int bar;
  foo() : bar(3) {}   //look, a constructor
  int getBar() 
  { 
    return bar; 
  }
};

foo f;
int y = f.getBar(); // y is 3

Learn ReactJs, React Native from akashmittal.com