mirror of
https://github.com/VictorEijkhout/TheArtOfHPC_vol3_cppf08programming.git
synced 2026-01-24 22:44:48 +09:00
33 lines
685 B
C++
33 lines
685 B
C++
/****************************************************************
|
|
****
|
|
**** This file belongs with the course
|
|
**** Introduction to Scientific Programming in C++/Fortran2003
|
|
**** copyright 2017/8 Victor Eijkhout eijkhout@tacc.utexas.edu
|
|
****
|
|
**** address.cxx : pointer from address
|
|
****
|
|
****************************************************************/
|
|
|
|
#include <iostream>
|
|
using std::cout;
|
|
|
|
#include <memory>
|
|
using std::shared_ptr;
|
|
|
|
class HasY {
|
|
public:
|
|
double y;
|
|
HasY( double y) : y(y) {};
|
|
};
|
|
|
|
int main() {
|
|
HasY y(5);
|
|
//codesnippet shareaddress
|
|
auto
|
|
p = shared_ptr<HasY>( &y );
|
|
p->y = 3;
|
|
cout << "Pointer's y: "
|
|
<< p->y << '\n';
|
|
//codesnippet end
|
|
}
|