mirror of
https://github.com/VictorEijkhout/TheArtOfHPC_vol3_cppf08programming.git
synced 2026-01-24 22:44:48 +09:00
37 lines
738 B
C++
37 lines
738 B
C++
/****************************************************************
|
|
****
|
|
**** This file belongs with the course
|
|
**** Introduction to Scientific Programming in C++/Fortran2003
|
|
**** copyright 2016/7 Victor Eijkhout eijkhout@tacc.utexas.edu
|
|
****
|
|
**** vectorpassnot.cxx : example of vector passed by value
|
|
****
|
|
****************************************************************/
|
|
|
|
#include <iostream>
|
|
using std::cin;
|
|
using std::cout;
|
|
|
|
#include <vector>
|
|
using std::vector;
|
|
|
|
//codesnippet vectorpassval
|
|
void set0
|
|
( vector<float> v,float x )
|
|
{
|
|
v.at(0) = x;
|
|
}
|
|
//codesnippet end
|
|
|
|
int main() {
|
|
|
|
//codesnippet vectorpassval
|
|
vector<float> v(1);
|
|
v.at(0) = 3.5;
|
|
set0(v,4.6);
|
|
cout << v.at(0) << '\n';
|
|
//codesnippet end
|
|
|
|
return 0;
|
|
}
|