qt编译multiple definition of错误

学习QT编程,编译时出现multiple definition of错误,

  4 people::people()
  5 {
  6     connect(this, SIGNAL(sig1()), this, SLOT(slo1()));
  7 }
  8
  9 people::~people()
 10 {}
 11 /*
 12 void people::sig1()
 13 {                                                                          
 14     printf("in sig.\n");
 15 }
 16 */
 17 void people::slo1()
 18 {
 19     printf("in slo.\n");
 20 }

原来,QT预处理工具会将people.cpp中宏展开为moc_people.cpp,moc_people.cpp中包含了

101 void people::sig1()
102 {
103     printf("in sig1.\n");
104     QMetaObject::activate(this, &staticMetaObject, 0, 0);
105 }

 

具体宏是怎么处理的,下面继续学习。

你可能感兴趣的:(init)