All pastes #244021 Raw Edit

Mine

public cpp v1 · immutable
#244021 ·published 2006-11-09 04:48 UTC
rendered paste body
#include <iostream>#include <utility>#include <string>#include <vector>#include "sample.h"using namespace std;// operator for writing sampleostream& operator<<(ostream &s, sample p) {	s << "<" << p.size() << ":";		for (int i = 0; i <= p.size() - 1; i++)		s << p.at(i) << " ";		s << ">";}// FROM HERE!istream& operator>>(istream &s, sample &p) {	char larrow, colon, rarrow;	int nTotal;		if (s >> larrow >> nTotal) {		if 	}		else s.setstate(ios::badbit); // read failed}istream& parse_inputs(istream &s, vector<double> &v) {        char[] buf = char[100];        int index = 0;        char newchar;	while (!s.eof()){                if(s.peek()=='>')                        break;                else                        s.get(newchar);                if (newchar == '0' || newchar == '1' || newchar == '2' || newchar == '3' || newchar == '4' ||                         newchar == '5' || newchar == '6' || newchar == '7' || newchar == '8' || newchar == '9'                        || newchar == '.'){                        buf[index++]=newchar;                        buf[index]='\0';                }else{                //here you need to code what to do when you hit a space.                //you have a buffer of chars, you need to make it into a double.                //don't forget to reset index to 0.                }        }}// TO HERE!int main() {	vector<double> vd(5);	vd[0] = 0;	vd[1] = 1.1;	vd[2] = 2.0;	sample s = vd;	cout << s;}