I have a list of Slide objects. Each Slide object has a vector of slide elements, the slide element vector is of another class,say ItemProperties that has members
int Resize int Rotate int Move
and the functions to modify these values
void ResizeItem(int resize_val);
void RotateItem(int rotate_val);
void MoveItem(int move_val);
I am iterating the list of object like this "Iterating Part"
auto slidelist_ptr=VDECK.getSlideList(); /*returns list<Slide> by reference */
auto slidelist_itr=slidelist_ptr.begin(); /*returns iterator to beginning of Slide list*/
auto slidelemnts_itr=slidelist_itr->getSlideElemnt().begin(); /*returns iterator to beginning of slide list elements*/
in1=_getch();
if(in1!=KEY_ARROW_1)
{
**VDECK.selectedSlideOperations((*slidelist_itr),in1-48);**
throw std::runtime_error("Operation success\n");
}
++slidelist_itr;
slidelemnts_itr=slidelist_itr->getSlideElemnt().begin();
In the function selectedSlideOperations , I am passing the particular slide object and taking it as reference in function like this
void Deck::selectedSlideOperations(Slide &obj,int choice)
{
switch(choice)
{
case 5:
ChangeSlideItemProperties(obj);
break;
} }
In ChangeSlideItemProperties , I am again taking the object as reference
void Deck::ChangeSlideItemProperties(Slide &obj)
{
for(auto p=obj.getSlideElemnt().begin();p!=obj.getSlideElemnt().end();p++)
{
std::cout<<"before \n";
p->PrintItemProperties();
p->RotateItem(input);
std::cout<<"\nafter \n";
p->PrintItemProperties();
}
}
Inside this I am iterating the Slide object's slide elements(which is a vector) and trying to modify the value of member "Rotate" for all the elements in vector. After modification when I print "before" and "after" the members ,the value reflects properly for member Rotate. However after modification ,when I exit this menu and print the slide elements using iteration as shown in "Iterating part" , the values are 0's for all the members.
I am fairly new to C++ , please bear with me.... I am not sure what am I missing here.
Aucun commentaire:
Enregistrer un commentaire