A
Azdo
Hello,
if i wanted to access the elements of an array which is owned by an
auto_ptr, as:
#include <memory>
int main(){
std::auto_ptr<int> p(new int[10]);
p[2]=2; //Error: no operator[] defined
return 0;
}
would the best way be:
#include <memory>
int main(){
std::auto_ptr<int> p(new int[10]);
int *p_;
p_=p.get();
p_[2]=2;
return 0;
}
I thought deriving a class from auto_ptr, but the pointer member is
protected and subject to have different names on different C++ standard
library implementations.
TIA,
if i wanted to access the elements of an array which is owned by an
auto_ptr, as:
#include <memory>
int main(){
std::auto_ptr<int> p(new int[10]);
p[2]=2; //Error: no operator[] defined
return 0;
}
would the best way be:
#include <memory>
int main(){
std::auto_ptr<int> p(new int[10]);
int *p_;
p_=p.get();
p_[2]=2;
return 0;
}
I thought deriving a class from auto_ptr, but the pointer member is
protected and subject to have different names on different C++ standard
library implementations.
TIA,