pointers to objects


1
2
3
4
5
6
Student *a;
Student *b = new Student();
Student *c = new Student();
a=b;
b=c;
c=a;


is this ^ the right way to switch between pointers?
Last edited on
Sure. They're just memory locations = values.
If you don't want to write the code for swapping two things yourself and risking making mistakes you can use std::swap from the <algorithm> header.
std::swap(a, b);
Topic archived. No new replies allowed.