User Tools

Site Tools


c_-_c_pointers:const_auto_ptr

C - C++ Pointers - const auto_ptr

#include <iostream>
#include <memory>
using namespace std;
 
int main()
{
  const auto_ptr<float> a(new float(20));
  const auto_ptr<int> b(new int(0));
  const auto_ptr<int> c;
 
  cout << "Before assigning values" << endl;
  cout << " a: ";cout<< a.get() <<endl;
  cout<<*a;
  cout << " \nb: " ;cout<<b.get()<<endl;
  cout <<*b;
  cout << " \nc: " ;cout<<c.get()<<endl;
 
  *b = *a;
  *a = 50.10;
 
  cout << "\nafter assigning values:" << endl;
  cout << " \na: ";cout<< a.get()<<endl;
  cout << *a;
  cout << " \nb: " ;cout<< b.get()<<endl;
  cout <<*b;
  cout << " \nc: " ;cout<< c.get()<<endl;
 
  return 0;
}
c_-_c_pointers/const_auto_ptr.txt · Last modified: 2020/07/15 10:30 by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki