#include<iostream>
#include<string.h>
using namespace std;
class FWQ
{
public:
string add;
string url;
string cmd;
virtual int service(string,string ,string )=0;
virtual void open()=0;
virtual void query()=0;
virtual void close()=0;
};
class DB:public FWQ
{
public:
int service(string add,string url,string cmd)
{
this->add=add;
this->url=url;
this->cmd=cmd;
void open();
void query();
void close();
return 0;
}
void open()
{
cout<<"正在访问数据库"<<url<<"..."<<endl<<endl;
}
void query()
{
cout<<"访问成功,正在处理数据中..."<<endl;
cout<<"处理数据的指令为:"<<cmd<<endl;
cout<<"处理成功!"<<endl<<endl;
}
void close()
{
cout<<"正在关闭数据库..."<<endl;
cout<<"已关闭数据库!"<<endl<<endl;
}
};
class FS:public FWQ
{
public:
int service(string add,string url,string cmd)
{
this->add=add;
this->url=url;
this->cmd=cmd;
void open();
void query();
void close();
return 0;
}
void open()
{
cout<<"正在访问目标文件"<<url<<"..."<<endl<<endl;
}
void query()
{
cout<<"访问成功,正在处理数据中..."<<endl;
cout<<"处理数据的指令为:"<<cmd<<endl;
cout<<"处理成功!"<<endl<<endl;
}
void close()
{
cout<<"正在关闭文件..."<<endl;
cout<<"已关闭文件!"<<endl<<endl;
}
};
int main()
{
DB db;
FS fs;
db.service("db","10.64.64","select* from user");
fs.service("fs","d:\\test","salary");
db.service("db","10.64.6.10","select* from book");
fs.service("fs","c:\\stu","student");
return 0;
}
这是我写的代码,调试不成功? |