2016-06-05 2 views
-1

Я пробовал каждое решение для этих ошибок в google, но не нашел ответа на эту проблему.Несколько ошибок ссылок в моем проекте: 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

+0

Так о ne предупреждений - это дублирующее определение. Существует символ с двумя реализациями. Это может быть вызвано функциями в файлах заголовков без встроенного. В другой проблеме отсутствуют символы - этап ссылки не может найти функцию. – mksteve

+0

Пожалуйста, добавьте некоторую информацию о дублирующих функциях определения - где они (заголовок или файл cpp), являются ли они встроенными/не встроенными. Добавьте информацию о том, где должны быть определены символы, которые отсутствуют, и первые две строки. – mksteve

+0

в вашей cpp, вы не префикс своего 'spllitFile' правильно. Эта функция является членом класса 'Cluster', и ваша реализация не префикса не является. – Gibet

ответ

0

Я добавляю больше файлов заголовков, это может помочь, beac Я вижу, никто не знает, где именно проблема. Спасибо.

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]) 


}; 
Смежные вопросы