Try this:
#include <vector>
#include <iostream>
void go(std::vector<int*>* pvec){
int ten=10, twenty=20, thirty=30;
int *pten = &ten;
int* ptwenty = &twenty;
int* pthirty = &thirty;
pvec->push_back(pten);
pvec->push_back(ptwenty);
pvec->push_back(pthirty);
std::cout << *(pvec->at(0)) << std::endl;
std::cout << *(pvec->at(1)) << std::endl;
std::cout << *(pvec->at(2)) << std::endl;
}
int main(){
std::vector<int*>* pvec = new std::vector<int*>();
go(pvec);
std::cout << *(pvec->at(0)) << std::endl;
std::cout << *(pvec->at(1)) << std::endl;
std::cout << *(pvec->at(2)) << std::endl;
return 0;
}
#include <vector>
#include <iostream>
void go(std::vector<int*>* pvec){
int ten=10, twenty=20, thirty=30;
int *pten = &ten;
int* ptwenty = &twenty;
int* pthirty = &thirty;
pvec->push_back(pten);
pvec->push_back(ptwenty);
pvec->push_back(pthirty);
std::cout << *(pvec->at(0)) << std::endl;
std::cout << *(pvec->at(1)) << std::endl;
std::cout << *(pvec->at(2)) << std::endl;
}
int main(){
std::vector<int*>* pvec = new std::vector<int*>();
go(pvec);
std::cout << *(pvec->at(0)) << std::endl;
std::cout << *(pvec->at(1)) << std::endl;
std::cout << *(pvec->at(2)) << std::endl;
return 0;
}
To copy to clipboard, switch view to plain text mode
Try it, if it displays the same set of numbers two times then you're damn lucky
Bookmarks