Files
Victor Eijkhout b13edff125 initial upload
2022-11-13 14:03:01 -06:00

37 lines
743 B
C++

/****************************************************************
****
**** This file belongs with the course
**** Introduction to Scientific Programming in C++/Fortran2003
**** copyright 2016/7 Victor Eijkhout eijkhout@tacc.utexas.edu
****
**** vectorpassref.cxx : example of vector passed by reference
****
****************************************************************/
#include <iostream>
using std::cin;
using std::cout;
#include <vector>
using std::vector;
//codesnippet vectorpassref
void set0
( vector<float> &v,float x )
{
v.at(0) = x;
}
//codesnippet end
int main() {
//codesnippet vectorpassref
vector<float> v(1);
v.at(0) = 3.5;
set0(v,4.6);
cout << v.at(0) << '\n';
//codesnippet end
return 0;
}