Hello all,
Firstly, let me apologize for anything out of the norm in this post; it is my first.
I have to write a program that parses an input file and generates a linked list for sequences of DNA. I have the i/o functions correct and am starting to work on the linked list. I have three classes (per request of my professor): sequenceDatabase - i/o, DNA - holds the data for each sequence (id, sequence, animal, etc.), and DNAList - holds pointers to each DNA object created (but NOT the actual object).
I am getting quite a few errors upon debugging in my DNAList.h file, most of which appear to stem from it not recognized "DNA" as a type. Below are a few of the errors:
"syntax error: missing ';' before '*'" - Line 11
"missing type specifier - int assumed..." - Line 11
"unexpected token(s) preceding ';'" - Line 11
These errors repeat each time I instantiate any type that uses DNA (regular, pointer, or references to DNA) in the DNAList header.
Below is DNAList.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
|
#ifndef DNALIST_H
#define DNALIST_H
#include "DNA.h"
#include "sequenceDatabase.h"
#include <string>
using std::string;
struct DNANode
{
DNA* data;
DNANode* next;
};
class DNAList
{
public:
DNAList();
bool push_back(DNA* newDNA);
DNANode* find(string id);
bool set(const DNA& x);
bool obliterate(string id);
int size();
~DNAList();
private:
int length;
DNANode* head;
};
#endif
|
Below is DNA.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
|
#ifndef DNA_H
#define DNA_H
#include "DNAList.h"
#include "sequenceDatabase.h"
#include <string>
using std::string;
class DNA
{
public:
//Default constructor. Sets length to 0 and leaves other data members uninitialized.
DNA();
//Constructor. Sets each data member
DNA(string rlabel, string rid, string rsequence, unsigned rlength, int rindex);
void print();
void get();
void set();
~DNA();
private:
string label, id, sequence;
unsigned length;
int index;
};
#endif
|
And finally, sequenceDatabase.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
|
#ifndef SEQUENCEDATABASE_H
#define SEQUENCEDATABASE_H
#include "DNA.h"
#include <fstream>
#include <string>
using std::string;
using std::ofstream;
using std::ifstream;
class SequenceDatabase
{
public:
SequenceDatabase();
SequenceDatabase(string ofname);
void importEntries(string ifname);
~SequenceDatabase();
private:
DNAList list;
ifstream fin;
ofstream fout;
unsigned count;
void Print();
void Obliterate();
void Entries();
void Add();
};
#endif
|
I have made my own linked lists before, but only with one templated class to which I passed a struct in the main file. What is going on?
Any suggestions or insights would be very much appreciated!
P.S: The implementation files are currently just skeleton code