I was playing around with some code today, and I came across the idea of putting a bunch of pairs in an array, but I havn’t been able to get it to work. Here are the code:
#include <utility>
#include <iostream>
std::pair<double,double> * pairArr;
int main(){
pairArr = new std::pair<double,double> [3]; //creating the array
pairArr [0] = make_pair(1.0,1.2); //Filling arbitrary numbers
pairArr [1] = make_pair(0.2,1.4);
pairArr [2] = make_pair(0.8,1.3);
std::cout<< pair[0].first << pair[1].second << pair[2].first //Output
return 0;
}
the output of this program is not all what I had input.
The program as posted does not compile.
Changing the output to
produces the expected result,
11.40.8, that is1 1.4 0.8without spaces: https://ideone.com/XAPHX