Answers for "function in struct c++"

C++
6

what is a struct in c++

struct Person
{
    char name[50];
    int age;
    float salary;
};
Posted by: Guest on August-06-2020
2

function in struct c++

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

foo f;
int y = f.getBar(); // y is 3
Posted by: Guest on September-14-2020

Browse Popular Code Answers by Language