Hello ladies and gents,
Wanted to make this part of an exercise in wich I enter each time two integers into an array for wich I have to use STL container vector.
Ive got this sofar, but getting an error message when I entered two numbers and the exe shuts down? I'm almost certain it's got to do with the
while (cin>> x >>" ">> y, !cin.fail())
But, not sure about it and even if, don't know how to solve it?
What Ive got sofar in total is this:
#include <iostream>
#include <vector>
using namespace std;
class point
{
private:
int x, y, z;
public:
point (int xx = 0, int yy = 0, int zz = 0): x (xx), y (yy), z (zz) {}
vector<int> s, t;
void numbers()
{
while (cin>> x >>" ">> y, !cin.fail())
{
s.push_back(x);
s.push_back(y);
}
}
void print()
{
int n = s.size();
for (z = 0; z < n; z++)
cout<< s[z] <<endl;
}
};
int main()
{
point u;
cout<<"Type twee integere getallen in per keer: "<<endl;
u.numbers();
u.print();
cin.get();
return 0;
}
Could someone please point me in the right direction, thank you ;)