How to edit original object through object* temp that points to original object?
So if I have an Object called Friend with a member called name.
I do
Code:
Friend* f1;
Friend* temp;
for(int i =0; i<2; i++){
f1->name = "BILL";
if(i == 0)
temp = f1;
if(i == 1)
temp->name = "LARRY";
}
When I iterate through my friend vector it still returns
BILL
BILL
instead of:
Larry
BILL
How can I make it return the above?
Re: How to edit original object through object* temp that points to original object?
1. Where and what is your so called "vector"?
2. W hatis the relationship between pointer to Friend object (Friend* f1) and a "vector"?
Re: How to edit original object through object* temp that points to original object?
...where do you initialise f1 and increment it?
Re: How to edit original object through object* temp that points to original object?
Please post compilable code.
What's the definition of your Friend class?
Where do you define your vector?
You are using f1 which is uninitialized.