C++问题,急急!!!

来源:百度知道 编辑:UC知道 时间:2024/06/10 18:48:33
在看C++多文件结构问题,老是有点疑惑;希望高手能提供一完整可运行的程序。万分感谢!!!!

应该这样放置文件的内容,这也是大家所使用的方式
----------------------------------------
main.cpp //主程序文件

#include "s.h"
#include "t.h"
int main(){
s s1;//编译未通过
return 0;
}
----------------------------------------
s.cpp //这个文件放的是类的函数实现
#include "s.h"

int s::func1()
{
}
int s::func2()
{
}
----------------------------------------
s.h //这个文件放的是这个类的实现
#ifndef _H_1_
#define _H_1_
class s{
public:
s() { x = 1; }
int func1();//类的其他函数
int func2();//类的其他函数
private:
int x;
};
#endif
----------------------------------------
t.cpp //这个文件放的是类的函数实现
#include "t.h"

int t::func1()
{
}
int t::func2()
{
}
----------------------------------------
t.h //这个文件放的是这个类的实现
#ifndef _H_1_
#define _H_1_
class t{
public:
t() { x = 1; }