Boost.Moveemulates C++ move semantics in C++03 compilers and allows writing portable code that works optimally in C++03 and C++ compilers.
HEADER
#include<iostream> #include<boost/move.hpp>
SYNTAX
class moveobject
void calc()
~SOURCE CODE~
#include<iostream>
#include<boost/move.hpp> usingnamespace boost; classmoveobject { public : int x,y; //declaring two moves,one is forward and one is backward. int man; //declaring the object as a man voidcalc() { cin>>man; //getting the objects position cout<<"Initially the man is at the position :"<<man<<endl; //printing cin>>x; //getting the forward move(steps) { man=man+x; //calculating the forward position cout<<"forward position of the man is :"<<man<<endl; //printing } cin>>y; //getting backward move(steps)
{ man=man-y; //calculating the backward positon cout<<"next position of the man is :"<<man<<endl; //printing } } }; intmain() //main function { moveobject M; M.calc(); return0; }
RUNTIME INPUT
10 //man
5 //x
2 //y
OUTPUT
Initially the man is at the position :10
forward position of the man is :15
next position of the man is :13
CONCLUSION
i have assumed an object as a man.
the forward position as x and the backward position as y.
then getting those moves.
and then calculating those moves.
finally printing the initial movement,forward position and backward(next)position of the man.
Comments