Clarifying structures for me.

closed account (91qLy60M)
Ladies and Gentlemen of Cplusplus.com, I have read a few things and am curious about structs. Everything I've read says to do;
1
2
3
4
5
6
7
struct Name{
      std::string first;
      std::string last;
};

Name name1;
Name name2;


I found a site that does it like so;
1
2
3
4
5
6
7
typedef struct{
      std::string first;
      std::string last;
}Name;

Name name1;
Name name2;

My question, how can the last one with typedef work like the one before it? I thought the object name had to follow the struct declaration like in the first one.
closed account (91qLy60M)
Thank you for that mobotus, sir.
Topic archived. No new replies allowed.