# beginner c++ question

**URL:** <https://boards.straightdope.com/t/beginner-c-question/664398>\
**Category:** Miscellaneous and Personal Stuff I Must Share\
**Created:** [July 24, 2013, 5:53pm UTC](https://boards.straightdope.com/t/beginner-c-question/664398 "2013-07-24T17:53:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![DaveBfd](https://avatars.discourse-cdn.com/v4/letter/d/c6cbf5/32.png) [@DaveBfd](https://boards.straightdope.com/u/DaveBfd)\
**Post date:** [July 24, 2013, 5:53pm UTC](https://boards.straightdope.com/t/beginner-c-question/664398/1 "2013-07-24T17:53:32Z")

</div>

How do you properly define a struct in a header file?

say I have globals.cpp:

struct User  
{  
int age;  
int weight;  
};

```
User dave = {11, 100};
User notdave = {45, 193};

```

How would I make globals.h so that the struct and its members are accessible from all files? so far all Ive seen is basically rewriting the struct in the header yet while doing that the members are still not defined globally.

---

<div class="post-metadata">

**Author:** ![twickster](https://avatars.discourse-cdn.com/v4/letter/t/ec9cab/32.png) [@twickster](https://boards.straightdope.com/u/twickster)\
**Post date:** [July 24, 2013, 6:16pm UTC](https://boards.straightdope.com/t/beginner-c-question/664398/2 "2013-07-24T18:16:45Z")

</div>

The OP has resolved this, so I’ll close this thread.
