#include <iostream>
#include <string>
using namespace std;
//メンバーの基底クラス
struct menber{
virtual void normalaccess() = 0;
virtual void adminaccess() = 0;
};
//管理者のクラス
struct root : public menber{
void normalaccess(){
cout << "rootなので通常アクセスが可能です" << endl;
}
void adminaccess(){
cout << "rootなので管理者アクセスが可能です" << endl;
}
};
//通常メンバーのクラス
struct normalmenber : public menber{
void normalaccess(){
cout << "normalmenberなので通常アクセスが可能です" << endl;
}
void adminaccess(){
cout << "normalmenberなので管理者アクセスは不可能です" << endl;
}
};
//メンバー以外のクラス
struct nomenber : public menber{
void normalaccess(){
cout << "nomenberなので通常アクセスは不可能です" << endl;
}
void adminaccess(){
cout << "nomenberなので管理者アクセスは不可能です" << endl;
}
};
//受付
struct front{
const string rootid;
const string normalid;
front(string rootid,string normalid) : rootid(rootid),normalid(normalid){}
menber * Login(const string & id){
//IDを元にどのメンバーか判断
if(rootid == id){
return new root();
}else if(normalid == id){
return new normalmenber();
}else{
return new nomenber;
}
}
};
int main(){
//受付の設定
front f("root","normalid");
//ログイン
menber * menber1 = f.Login("root");
menber * menber2 = f.Login("normalid");
menber * menber3 = f.Login("husinsya");
//menber1による何かしらの操作
menber1->normalaccess();
menber1->adminaccess();
//menber2による何かしらの操作
menber2->normalaccess();
menber2->adminaccess();
//menber3による何かしらの操作
menber3->normalaccess();
menber3->adminaccess();
delete menber1;
delete menber2;
delete menber3;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3RyaW5nPgoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCi8v44Oh44Oz44OQ44O844Gu5Z+65bqV44Kv44Op44K5CnN0cnVjdCBtZW5iZXJ7Cgl2aXJ0dWFsIHZvaWQgbm9ybWFsYWNjZXNzKCkgPSAwOwoJdmlydHVhbCB2b2lkIGFkbWluYWNjZXNzKCkgPSAwOwp9OwoKLy/nrqHnkIbogIXjga7jgq/jg6njgrkKc3RydWN0IHJvb3QgOiBwdWJsaWMgbWVuYmVyewoJdm9pZCB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