Click to See Complete Forum and Search --> : C++ help


Obrion
02-12-2003, 02:35 AM
ok this is ticking me off.. i have spent 3 hours trying to figure out why my output is incorrect... i am reading 3 numbers in from a file.
and i have an assload of functions i am going to use on those numbers ( don't want to get into detail about it would take to long) but anywho it seems to output -9.2555 +222 or something when i out put the values..... my data file has one line right now
1 2 3



here is the program

#include <iostream>
#include <fstream>
#include <stdlib.h>
#include <cmath>
#define PI 3.14159
#include "classes.h"
using namespace std; //yeah yeah ***** away... it is just easier right now


int main()
{
Getdata g;
//Functions f;
//Output o;
double l,h,w;
//o.printing(l);
cout<<l<<h<<w<<endl;

return 0;
}


------------------------------here is the first part of the header file
#include <iostream>
#include <fstream>
#include <stdlib.h>
#ifndef CLASS_H
#define CLASS_H
using namespace std; //yeah yeah i know somebody is going to ***** about this


//*************************************************c lass for input of data
class Getdata{

public:
Getdata();
bool getamount(double & l , double & w, double & h);


private:
ifstream listing;

};

// Constructor Function for getting input

Getdata::Getdata(): listing("boxdata.dat")
{ // exit program if ifstream could not open file

if ( !listing ) {
cerr << "File could not be opened" << endl;
exit( 1 );
}
}
// end of constructor function

bool Getdata::getamount(double & l, double & w, double & h)
{
return ( listing >> l >> w>> h);
}

Obrion
02-12-2003, 02:49 AM
hahaha nevermind i figured it out..

i forgot to pass g to getamount