//mainwindow.h
class CA{
private:
QString str;
public:
void CA();
void func();
~CA();
};
//mainwindow.c
#include "mainwindow.h"
void CA::CA(){
int len = str.size();//可以直接调用str对象了因为,在mainwindow.h中已经定义了QString str;
} //而该cpp文件中也包含了"mainwindow.h"
void CA::func(){
//do sth.
}