?????????c++???
???????????? ???????[ 2014/6/20 11:39:38 ] ????????c++ net
??????2??
Test_Observer.cpp
/*
???????????и?????????????????
*/
#include <iostream>
#include <string>
#include <vector>
using namespace std;
class Observer
{
protected:
string name;
public:
virtual void update()
{
cout<<"Observer"<<endl;
}
};
class Man:public Observer
{
public:
Man(string name)
{
this->name=name;
}
void update()
{
cout<<name<<" Man is coming"<<endl;
}
};
class Woman:public Observer
{
public:
Woman(string name)
{
this->name=name;
}
void update()
{
cout<<name<<" Woman is leaving"<<endl;
}
};
class Subject
{
private:
vector<Observer*> obser;
public:
void add(Observer &ob)
{
obser.push_back(&ob);
}
void notify()
{
for (vector<Observer*>::iterator it=obser.begin(); it!=obser.end(); it++)
{
(*it)->update();
}
}
};
int main()
{
Subject secret;
Man m1("m1--");
Man m2("m2--");
Woman w1("w1");
Woman w2("w2");
secret.add(m1);
secret.add(m2);
secret.add(w1);
secret.add(w2);
secret.notify();
return 0;
}
|
???????????????????????漰???????????????????SPASVOС??(021-61079698-8054)?????????????????????????
??????
??C++????????????C++ lvalue??rvalueC++11????????C++???????????????C++?е?????????????????C++?????????C++???Windows????λ??C/C++???????????????????JAVA??C??C++??????????c++??python???????????????????????????????C++???????C++?е????????C++????????????????C++ ???????????????C++?????????????????????C++????????????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11????????
?????????App Bug???????????????????????Jmeter?????????QC??????APP????????????????app?????е????????jenkins+testng+ant+webdriver??????????????JMeter????HTTP???????Selenium 2.0 WebDriver ??????