Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Vectors Functions

I am trying to use this code below to combine it will another program that works and this program here should allow it to undo and redo whatever the other program (the one that works) is doing. How can the one given here be modified to allow operation for undo?
[code]#include
#include
using namespace std;

template
class AClass
{
public:
avar var1;
bvar var2;
cvar var3;
AClass (const avar& v1, const bvar& v2, const cvar& v3)
: var1(v1), var2(v2), var3(v3) {}

void forward(const AClass &a)
{
//get current position and go plus 1
//avector.push_back();
}
int back(const AClass &a)
{
//get current position and go back 1
//display content of current position
//avector.pop_back();
}
};

int main()
{
vector > avector;
AClass obj1(1,2,3);

avector.push_back(obj1); //how can I use he function forward(obj1) instead?
for( int i = 0; i < avector.size(); i++ ){
cout<<obj1.var1;
cout<<obj1.var2;
cout<<obj1.var3;
cout<<endl;
}
AClass<int, int, int> obj2(4,5,6);
avector.pop_back(); //can I use the function back(obj1) instead?
cout<<obj2.var1;
cout<<obj2.var2;
cout<<obj2.var3;
cout<<endl;
}[/code]

regards,

John
Sign In or Register to comment.