Issue with class composition and method
Jul 31, 2015 at 9:11am UTC
I'm working on this I/O system and Eclipse is being a pain by giving me an error. I'm using a function that has been declared and implemented but the text-editor is telling me (
Method could not be resolved ). I included the header in which the function is an there's still no hopes of clearing this error.
To add salt to the wound, the open() function from library fstream acts up and tells me I'm using invalid arguments as I am typing this.
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
/*
* data.h
*
* Created on: Jul 30, 2015
* Author: jackymoon
*/
#ifndef DATA_H_
#define DATA_H_
#include "lineseq.h"
template <typename T>
class Data {
public :
Data(int numbLines) :
currentLine(0),
numberLines(numbLines)
{
linePtr = new linePtr[numberLines];
}
~Data(){}
void add(std::string type, int size, std::string seq){
linePtr[currentLine++] = linePtr(type,size,seq);
} //<--- HERE I DECLARE MY FUNCTION
private :
int currentLine;
int numberLines;
LineSeq *linePtr;
};
#endif /* DATA_H_ */
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
/*
* reader.h
*
* Created on: Jul 31, 2015
* Author: jacky
*/
#ifndef READER_H
#define READER_H
#include "data.h"
#include "lineseq.h"
#include <fstream>
#include <string>
template <typename T>
class Reader{
public :
void ReadAndWrite(const std::string filepath) {
Data Datastorage(10); //for demo purposes
std::ifstream read;
read.open(filepath); //ERROR highlighting open (invalid arguments)
while (read.eof()){
while (read >> dType){
read >> dSize;
std::getline(read, dSeq);
Datastorage.add(dType, dSize, dSeq); //ERROR method could not be resolved.
}
}
}
private :
std::string dType;
int dSize;
std::string dSeq;
};
#endif
To me these errors don't seem to make sense. Am I actually wrong here or is there an issue with my compiler?
Last edited on Aug 1, 2015 at 8:09am UTC
Jul 31, 2015 at 10:01am UTC
You say:
the text-editor is telling me (Method could not be resolved ).
Does your code actually compile?
Last edited on Jul 31, 2015 at 10:02am UTC
Jul 31, 2015 at 6:53pm UTC
No it doesn't compile because of those two highlighted errors
Topic archived. No new replies allowed.