我项目中的几个链接错误:LNK2019,LNK2005

时间:2016-06-05 21:23:21

标签: c++ lnk2019 lnk2005

我在谷歌尝试了解决这些错误的所有解决方案,但没有找到解决此问题的答案。

项目非常大,但这里有一个文件:

cpp文件:

#include"Cluster.h"


Cluster::Cluster()
{}

Cluster::~Cluster() //close files and reomve dynamically-allocated memory

{
Splittedfile.close();
clustring.close();
Linefile.close();

delete[] protein;
delete[] NextProtein;
}


void spllitFile()
{
// check length of the file, and set length of NumOfSeq
Linefile.seekg(0, Linefile.end);
long sizeOfFile = Linefile.tellg();
NumOfProteins = sizeOfFile - 20;

//from the begining of LineFile:
//read 1 protein from LineFile & write it to Splittedfile. 
//Each loop is advaced with:
// /n to Splittedfile & another 1 character "slide" in LineFile.

Linefile.seekg(ios_base::beg);
char* CopyProtein = new char[20];  // allocate buffer for reading 1 protein
long startPlaceOfRead = 0;

while (!(Linefile.eof()))
{
    if ((startPlaceOfRead != 0) || (((sizeOfFile - startPlaceOfRead) <     20.0)))
        Splittedfile << "\n";
    Linefile.seekg(startPlaceOfRead);//to next protein - one for enter. one     for back
    if ((sizeOfFile - startPlaceOfRead) < 20.0) break;//if not enough for 1 protein
    Linefile.read(CopyProtein, 20);   // read 1 protein from infile

    Splittedfile.write(CopyProtein, 20);// write to outfile

    startPlaceOfRead++;
}
delete[] CopyProtein;  // release dynamically-allocated memory
}

void buildClustrs()
{
    Form Form;

char X[] = "XXXXXXXXXXXXXXXXXXXX‎‎‎‎««««««««";
int removed = 0;
for (int first = 0; first <= NumOfProteins; first++)//for the 1st
{
    Splittedfile.seekg(0);
    Splittedfile.seekg(first * 20 + 2 * first, ios_base::beg);
    //int ThisPlace = Splittedfile.tellg();

    Splittedfile.read(protein, 20);
    if (strcmp(X, protein) == 0)  continue; // 0= EQUAL

    clustring << "\n\n\n";
    clustring.write(protein, 20);
    cout << "protein number " << first << " written as a lonely cluster " << endl; // WHEN FOUND belonging only-printing!


    //remove this protein
    Splittedfile.seekg(-20, Splittedfile.cur);
    Splittedfile << "XXXXXXXXXXXXXXXXXXXX";
    removed++;

    for (int Allother = first + 1; Allother <= NumOfProteins; Allother++) //the following protein
    {
        Splittedfile.seekg(Allother * 20 + 2 * Allother);
        Splittedfile.read(NextProtein, 20);   // READ next protein, -read -go on automaticly-
        if (strcmp(X, NextProtein) == 0)  continue;
        if ( (Form.Compare2Proteins (protein, NextProtein) ) !=-1)//>=60%       
        {
            clustring << "\n";
            clustring.write(NextProtein, 20);// write to clustring second protein in cluster
            cout << "protein number " << Allother << " written to cluster " << first << endl; // WHEN FOUND belonging only-printing!
            //remove this protein
            Splittedfile.seekg(-20, Splittedfile.cur);//to next protein 
            Splittedfile << "XXXXXXXXXXXXXXXXXXXX";
            removed++;
        }
    }
}

}

标题文件:

#pragma once
#include <iostream>
#include <string.h>
#include <fstream>
#include <sstream>
#include <tchar.h>
#include <string.h>

#include "Main.h"
#include "Form.h"


using namespace std;


class Cluster
{
public:
Cluster();
~Cluster();
void spllitFile();
void buildClustrs();
};

带错误的屏幕截图: errors

1 个答案:

答案 0 :(得分:0)

我添加了更多的头文件,它可能有所帮助,因为我看到没有人知道问题究竟在哪里。谢谢。

form.h:

#pragma once
#include <string>
#include <tchar.h>
#include <string.h>

using namespace std;

char *formString[6] = { "111100", "111010", "101110", "110110", "111001",     "110101" };
class Form
{
    public:
    Form();
    ~Form();

//void spllitBySizeOfForm(int sizeOfForm, char protein[20], int i);

int Compare2Proteins(char *protein1, char *Nextprotein);

char* stringXform(char str[6], char form[6]);
};

HashEntry.h:

#pragma once
#include <string>
#include <tchar.h>
#include <string.h>

using namespace std;

class HashEntry
{
public:
HashEntry(int key, int value);
int getValue();
int getKey();
};

HashMap.h:

#pragma once
#include <iostream>
#include <string>
#include <fstream>
#include <sstream>
#include <tchar.h>
#include <string.h>

#include "HashEntry.h"


using namespace std;
const int TABLE_SIZE = 20;

class HashMap
{
public:
HashMap::HashMap();// 
HashMap::~HashMap();
int get(int key); // get value. for example: B--> get 0.
void put(int key, int value);//build entry AND put value in it.
void PutHmap(); // Put values to HashMap. get it by Hmap.get
};

main.h:

#pragma once
#include <iostream>
#include <string.h>
#include <fstream>
#include <sstream>
#include <tchar.h>
#include <string.h>

#include "Cluster.h"



using namespace std;

long NumOfProteins = 0;
char* protein = new char[20];   // allocate memory for file content
char* NextProtein = new char[20];   // allocate memory for file content

fstream Splittedfile;
fstream newClusering;
ofstream clustring;
ifstream Linefile;

class Main
{
public:

//void position(char form[6], char str[6])


};