Overloaded input operator recognized in Windows but not Ubuntu
This has to be the oddest error I have ever come across. My overloaded input is recognized in windows but Ubuntu provides this error.
no match for the operator>>
Have I use a windows only implementation ?
.h
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <cmath>
#include <cstdio>
#include <cstdlib>
private:
vector<node*> i;
friend ifstream& operator>> (ifstream&, vector<node*> &);
|
.cpp
1 2 3 4 5 6
|
filereader(){
ifstream i(filename);
i >> vec;
}
ifstream& operator>> (ifstream& in, vector<node*> &n){// Logic}
|
are those fields supposed to be not inside a class?
They are within a class, I just gave the relevant elements of it
It's hard to know what is wrong when you post code that is incomplete.
As request, please see below
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
|
#ifndef FILEHANDLER_H
#define FILEHANDLER_H
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include "../circle/circle.h"
#include "../polygon/polygon.h"
#include "../scale/scale.h"
#include "../translate/translate.h"
using namespace std;
class filehandler
{
public:
filehandler(void);
~filehandler(void);
vector<node*> readfile(char** argv);
private:
vector<node*> scenegraph;
friend ifstream& operator>> (ifstream&, vector<node*> &);
//friend fstream& operator>> (fstream&, vector<node*> &);
};
#endif
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
vector<node*> filehandler::readfile(char** argv){
ifstream ifs(argv);
ifstream ifs("file1.txt");
//fstream filestr;
//filestr.open ("file1.txt", fstream::in | fstream::out | fstream::app);
//vector<node*> &s;
//if(!ifs){
if(!filestr){
// Error Message Necessary
}else {
try {
ifstream ifs("file1.txt");
ifs >> scenegraph;
//filestr >> s;
}catch(vector<node*>){
}
}
return scenegraph;
}
ifstream& operator>> (ifstream& in, vector<node*> &p){//Logic}
|
Topic archived. No new replies allowed.