The difference between typedef_struct and struct

  • 2020-04-02 02:03:34
  • OfStack


#include <iostream> 
using namespace std;
void main()
{
 int x;
 //MSG1 is an alias for structure A
 typedef struct A{
  int age;
  char s;
  }MSG1,*p1;
 MSG1 msg1 ;
 msg1.age=10;
 p1 point =&msg1;
 //Msg2 as a variable of structure B
 struct B{
  int age;
  char s;
 }msg2,*p2 = new B;
 msg2.age = 3;
 p2->age=4;
//
 cout<<(*point).age<<endl<<msg2.age;
//
 cin>>x;
}


Related articles: