// Command. cpp: defines the entry point of the console application.
//
/*
This is the simplest method.
*/
# Include "stdafx. H"
# Include <iostream>
Using namespace STD;
Class command
{
Public:
Command ()
{
}
Virtual ~ Command ()
{
}
Virtual void execute () = 0;
};
Class Cycler
{
Public:
Explorer ()
{
}
Virtual ~ Explorer ()
{
}
Void action ()
{
Cout <"do execution in reveiver" <Endl;
}
};
Class concretecommand: Public command
{
Public:
Concretecommand (Explorer * r): m_preceiver (r)
{
}
Virtual ~ Concretecommand ()
{
}
Virtual void execute ()
{
M_preceiver-> action ();
}
PRIVATE:
Extends er * m_preceiver;
};
Class invoker
{
Public:
Invoker (command * m): m_command (m)
{
}
Virtual ~ Invoker ()
{
}
Void invoke ()
{
If (null! = M_command)
M_command-> execute ();
}
PRIVATE:
Command * m_command;
};
Int _ tmain (INT argc, _ tchar * argv [])
{
Aggreger * r = new aggreger ();
Command * CM = new concretecommand (R );
Invoker * ik = new invoker (CM );
Ik-> invoke ();
Delete R;
Delete cm;
Delete ik;
Return 0;
}