#include <iostream>
#include <fstream>
#include <stdio.h>
#include "evalulation_criteria.h"
usingnamespace std;
int main( int argc, char** argv )
{
evaluation_criteria e_criteria
ofstream save_inv;
save_inv.open("saved_data_invariant.txt");
while(.....) { //OpenCV structures follow
//call to member function of class e_criteria
}
save_inv.close();
}
//class header
#ifndef EVALUTATION_CRITERIA_H_
#define EVALUTATION_CRITERIA_H_
#include "opencv/cxcore.h"
#include "opencv/cv.h"
#include <fstream>
usingnamespace std;
class evalutation_criteria {
private:
extern ofstream save_inv;
// other member data
public:
//member data
};
#endif /* EVALUTATION_CRITERIA_H_ */
//class implementation
#include <iostream>
#include "opencv/cv.h"
#include "opencv/highgui.h"
#include "opencv/cxcore.h"
#include "evalutation_criteria.h"
usingnamespace std;
// void constructor and destructor
void evalutation_criteria::calc(....){
save_inv<<(float) value;
}
I get only the "storage class specified for save_inv" error. I have checked the program many times for any missing semicolons but it compiles fine if i remove the extern keyboard (which is clearly not the purpose)....How do I pass the ofstream objects between main and class member functions to write to the same txt file then?
thanks coder777 for that serious error. i cant send the
ofstream &save_inv
to the function as it hampers my requirements. I tried creating save_inv as a global object but the error still lingers. I know global variables are not a good programming practice, but since I am developing an algorithm solely it should be fine I guess.