использование функций класса c ++ string для создания «подстрок гена» из более длинной исходной строки Genome

0

Пожалуйста помоги

//purpose:  find Genes in genome  and cout found genes


#include <iostream>
#include <string>
#include <cctype>
#include <cmath>
#include <algorithm>
using namespace std;

int main() 
{

    string genome = "TTATGTTTTAAGGATGGGGCGTTAGTT"; //using this string to test my code 
    //cout << "Enter a genome string: \n";
    //cin >> genome;

    cout <<genome.find("ATG") <<endl;

    while(!genome.empty())  //enters loop if strings not empty
    {
    if(genome.find("ATG",0) == npos) //genome.find("ATG",0,3) should return npos if no ATG is found right? 
    {                                 //Tried this if statment with = and == but no difference  
        genome.clear(); 
    }
    else
    {
        int startGene = genome.find("ATG",0); //ATG is not part of gene just a front endcap to genes
        int endGene = min(min(genome.find("TAG"), genome.find("TAA")), genome.find("TGA"));//endcaps are TAG or TAA or TGA 
                                                                                           //finds location of (1+ gene end) 


        string currentGene = genome.substr(startGene + 3, endGene - (startGene +3)) <<endl; //puts copy of gene in substring

        if((currentGene.length() % 3) == 0);
        {
            cout << currentGene; //a gene is a multiple of three characters so if its a gene I cout the gene
        }

        endGene += 3;
        genome.erase(0, (endGene)); //should erase the gene I just "cout"displayed 
                                                    //and its front ATG and its endcap and anything before its ATG

        cout << genome; //testing: this should display the genome after the endcap of the last gene cause I erased all coming before 
    }
    }



    return 0;
}

конец моего кода здесь проблема с

if(genome.find("ATG",0) == npos)

он называет npos недвусмысленным идентификатором, я думаю. Я думал, что npos - это то, что find вернется, если он не найдет ATG

theres проблема с этим, которую я нахожу странным, поскольку он работал, когда я не помещал его в переменную currentGene, а просто использовал cout для этой подстроки

string currentGene = genome.substr(startGene + 3, endGene - (startGene +3)) <<endl;

это говорит

010\projects\genome\genome\genome.cpp(34): error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,const std::basic_string<_Elem,_Traits,_Alloc> &)' : could not deduce template argument for 'std::basic_ostream<_Elem,_Traits> &' from 'std::basic_string<_Elem,_Traits,_Ax>'

другая проблема

if((currentGene.length() % 3) == 0);
        {
            cout << currentGene; //a gene is a multiple of three characters so if its a gene I cout the gene
        }



error report cut a litle of the repeats at the end

1>------ Build started: Project: genome, Configuration: Debug Win32 ------
1>Build started 11/26/2013 11:49:10 PM.
1>InitializeBuildStatus:
1>  Touching "Debug\genome.unsuccessfulbuild".
1>ClCompile:
1>  genome.cpp
1>c:\documents and settings\dell\my documents\visual studio 2010\projects\genome\genome\genome.cpp(34): error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,const std::basic_string<_Elem,_Traits,_Alloc> &)' : could not deduce template argument for 'std::basic_ostream<_Elem,_Traits> &' from 'std::basic_string<_Elem,_Traits,_Ax>'
1>          with
1>          [
1>              _Elem=char,
1>              _Traits=std::char_traits<char>,
1>              _Ax=std::allocator<char>
1>          ]
1>          c:\program files\microsoft visual studio 10.0\vc\include\string(489) : see declaration of 'std::operator <<'
1>c:\documents and settings\dell\my documents\visual studio 2010\projects\genome\genome\genome.cpp(34): error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,const std::basic_string<_Elem,_Traits,_Alloc> &)' : could not deduce template argument for 'std::basic_ostream<_Elem,_Traits> &' from 'std::basic_string<_Elem,_Traits,_Ax>'
1>          with
1>          [
1>              _Elem=char,
1>              _Traits=std::char_traits<char>,
1>              _Ax=std::allocator<char>
1>          ]
1>          c:\program files\microsoft visual studio 10.0\vc\include\string(489) : see declaration of 'std::operator <<'
1>c:\documents and settings\dell\my documents\visual studio 2010\projects\genome\genome\genome.cpp(34): error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,const std::basic_string<_Elem,_Traits,_Alloc> &)' : could not deduce template argument for 'std::basic_ostream<_Elem,_Traits> &' from 'std::basic_string<_Elem,_Traits,_Ax>'
1>          with
1>          [
1>              _Elem=char,
1>              _Traits=std::char_traits<char>,
1>              _Ax=std::allocator<char>
1>          ]
1>          c:\program files\microsoft visual studio 10.0\vc\include\string(489) : see declaration of 'std::operator <<'
1>c:\documents and settings\dell\my documents\visual studio 2010\projects\genome\genome\genome.cpp(34): error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,const std::error_code &)' : could not deduce template argument for 'std::basic_ostream<_Elem,_Traits> &' from 'std::basic_string<_Elem,_Traits,_Ax>'
1>          with
1>          [
1>              _Elem=char,
1>              _Traits=std::char_traits<char>,
1>              _Ax=std::allocator<char>
1>          ]
1>          c:\program files\microsoft visual studio 10.0\vc\include\ostream(1085) : see declaration of 'std::operator <<'
1>c:\documents and settings\dell\my documents\visual studio 2010\projects\genome\genome\genome.cpp(34): error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,const std::error_code &)' : could not deduce template argument for 'std::basic_ostream<_Elem,_Traits> &' from 'std::basic_string<_Elem,_Traits,_Ax>'
1>          with
1>          [
1>              _Elem=char,
1>              _Traits=std::char_traits<char>,
1>              _Ax=std::allocator<char>
1>          ]
1>          c:\program files\microsoft visual studio 10.0\vc\include\ostream(1085) : see declaration of 'std::operator <<'
1>c:\documents and settings\dell\my documents\visual studio 2010\projects\genome\genome\genome.cpp(34): error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,const std::error_code &)' : could not deduce template argument for 'std::basic_ostream<_Elem,_Traits> &' from 'std::basic_string<_Elem,_Traits,_Ax>'
1>          with
1>          [
1>              _Elem=char,
1>              _Traits=std::char_traits<char>,
1>              _Ax=std::allocator<char>
1>          ]
1>          c:\program files\microsoft visual studio 10.0\vc\include\ostream(1085) : see declaration of 'std::operator <<'
1>c:\documents and settings\dell\my documents\visual studio 2010\projects\genome\genome\genome.cpp(34): error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &&,_Ty)' : could not deduce template argument for 'std::basic_ostream<_Elem,_Traits> &&' from 'std::basic_string<_Elem,_Traits,_Ax>'
1>          with
1>          [
1>              _Elem=char,
1>              _Traits=std::char_traits<char>,
1>              _Ax=std::allocator<char>
1>          ]
1>          c:\program files\microsoft visual studio 10.0\vc\include\ostream(968) : see declaration of 'std::operator <<'
1>c:\documents and settings\dell\my documents\visual studio 2010\projects\genome\genome\genome.cpp(34): error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &&,_Ty)' : could not deduce template argument for 'std::basic_ostream<_Elem,_Traits> &&' from 'std::basic_string<_Elem,_Traits,_Ax>'
1>          with
1>          [
1>              _Elem=char,
1>              _Traits=std::char_traits<char>,
1>              _Ax=std::allocator<char>
1>          ]
1>          c:\program files\microsoft visual studio 10.0\vc\include\ostream(968) : see declaration of 'std::operator <<'
1>c:\documents and settings\dell\my documents\visual studio 2010\projects\genome\genome\genome.cpp(34): error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &&,_Ty)' : could not deduce template argument for 'std::basic_ostream<_Elem,_Traits> &&' from 'std::basic_string<_Elem,_Traits,_Ax>'
1>          with
1>          [
1>              _Elem=char,
1>              _Traits=std::char_traits<char>,
1>              _Ax=std::allocator<char>
1>          ]
1>          c:\program files\microsoft visual studio 10.0\vc\include\ostream(968) : see declaration of 'std::operator <<'
1>c:\documents and settings\dell\my documents\visual studio 2010\projects\genome\genome\genome.cpp(34): error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,unsigned char)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'std::basic_string<_Elem,_Traits,_Ax>'
1>          with
1>          [
1>              _Elem=char,
1>              _Traits=std::char_traits<char>,
1>              _Ax=std::allocator<char>
1>          ]
1>          c:\program files\microsoft visual studio 10.0\vc\include\ostream(958) : see declaration of 'std::operator <<'
1>c:\documents and settings\dell\my documents\visual studio 2010\projects\genome\genome\genome.cpp(34): error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,unsigned char)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'std::basic_string<_Elem,_Traits,_Ax>'
1>          with
1>          [
1>              _Elem=char,
1>              _Traits=std::char_traits<char>,
1>              _Ax=std::allocator<char>
1>          ]
1>          c:\program files\microsoft visual studio 10.0\vc\include\ostream(958) : see declaration of 'std::operator <<'
1>c:\documents and settings\dell\my documents\visual studio 2010\projects\genome\genome\genome.cpp(34): error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,unsigned char)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'std::basic_string<_Elem,_Traits,_Ax>'
1>          with
1>          [
1>              _Elem=char,
1>              _Traits=std::char_traits<char>,
1>              _Ax=std::allocator<char>
1>          ]
1>          c:\program files\microsoft visual studio 10.0\vc\include\ostream(958) : see declaration of 'std::operator <<'
1>c:\documents and settings\dell\my documents\visual studio 2010\projects\genome\genome\genome.cpp(34): error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,const unsigned char *)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'std::basic_string<_Elem,_Traits,_Ax>'
1>          with
1>          [
1>              _Elem=char,
1>              _Traits=std::char_traits<char>,
1>              _Ax=std::allocator<char>
1>          ]
1>          c:\program files\microsoft visual studio 10.0\vc\include\ostream(951) : see declaration of 'std::operator <<'
1>c:\documents and settings\dell\my documents\visual studio 2010\projects\genome\genome\genome.cpp(34): error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,const unsigned char *)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'std::basic_string<_Elem,_Traits,_Ax>'
1>          with
1>          [
1>              _Elem=char,
1>              _Traits=std::char_traits<char>,
1>              _Ax=std::allocator<char>
1>          ]
1>          c:\program files\microsoft visual studio 10.0\vc\include\ostream(951) : see declaration of 'std::operator <<'
1>c:\documents and settings\dell\my documents\visual studio 2010\projects\genome\genome\genome.cpp(34): error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,const unsigned char *)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'std::basic_string<_Elem,_Traits,_Ax>'
1>          with
1>          [
1>              _Elem=char,
1>              _Traits=std::char_traits<char>,
1>              _Ax=std::allocator<char>
1>          ]
1>          c:\program files\microsoft visual studio 10.0\vc\include\ostream(951) : see declaration of 'std::operator <<'
1>c:\documents and settings\dell\my documents\visual studio 2010\projects\genome\genome\genome.cpp(34): error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,signed char)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'std::basic_string<_Elem,_Traits,_Ax>'
1>          with
1>          [
1>              _Elem=char,
1>              _Traits=std::char_traits<char>,
1>              _Ax=std::allocator<char>
1>          ]
1>          c:\program files\microsoft visual studio 10.0\vc\include\ostream(944) : see declaration of 'std::operator <<'
1>c:\documents and settings\dell\my documents\visual studio 2010\projects\genome\genome\genome.cpp(34): error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,signed char)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'std::basic_string<_Elem,_Traits,_Ax>'
1>          with
1>          [
1>              _Elem=char,
1>              _Traits=std::char_traits<char>,
1>              _Ax=std::allocator<char>
1>          ]
1>          c:\program files\microsoft visual studio 10.0\vc\include\ostream(944) : see declaration of 'std::operator <<'
1>c:\documents and settings\dell\my documents\visual studio 2010\projects\genome\genome\genome.cpp(34): error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,signed char)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'std::basic_string<_Elem,_Traits,_Ax>'
1>          with
1>          [
1>              _Elem=char,
1>              _Traits=std::char_traits<char>,
1>              _Ax=std::allocator<char>
1>          ]
1>          c:\program files\microsoft visual studio 10.0\vc\include\ostream(944) : see declaration of 'std::operator <<'
1>c:\documents and settings\dell\my documents\visual studio 2010\projects\genome\genome\genome.cpp(34): error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,const signed char *)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'std::basic_string<_Elem,_Traits,_Ax>'
1>          with
1>          [
1>              _Elem=char,
1>              _Traits=std::char_traits<char>,
1>              _Ax=std::allocator<char>
1>          ]
1>          c:\program files\microsoft visual studio 10.0\vc\include\ostream(937) : see declaration of 'std::operator <<'
1>c:\documents and settings\dell\my documents\visual studio 2010\projects\genome\genome\genome.cpp(34): error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,const signed char *)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'std::basic_string<_Elem,_Traits,_Ax>'
1>          with
1>          [
1>              _Elem=char,
1>              _Traits=std::char_traits<char>,
1>              _Ax=std::allocator<char>
1>          ]
1>          c:\program files\microsoft visual studio 10.0\vc\include\ostream(937) : see declaration of 'std::operator <<'
1>c:\documents and settings\dell\my documents\visual studio 2010\projects\genome\genome\genome.cpp(34): error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,const signed char *)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'std::basic_string<_Elem,_Traits,_Ax>'
1>          with
1>          [
1>              _Elem=char,
1>              _Traits=std::char_traits<char>,
1>              _Ax=std::allocator<char>
1>          ]
1>          c:\program files\microsoft visual studio 10.0\vc\include\ostream(937) : see declaration of 'std::operator <<'
1>c:\documents and settings\dell\my documents\visual studio 2010\projects\genome\genome\genome.cpp(34): error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,_Elem)' : could not deduce template argument for 'std::basic_ostream<_Elem,_Traits> &' from 'std::basic_string<_Elem,_Traits,_Ax>'
1>          with
1>          [
1>              _Elem=char,
1>              _Traits=std::char_traits<char>,
1>              _Ax=std::allocator<char>
1>          ]
1>          c:\program files\microsoft visual studio 10.0\vc\include\ostream(898) : see declaration of 'std::operator <<'
1>c:\documents and settings\dell\my documents\visual studio 2010\projects\genome\genome\genome.cpp(34): error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,_Elem)' : could not deduce template argument for 'std::basic_ostream<_Elem,_Traits> &' from 'std::basic_string<_Elem,_Traits,_Ax>'
1>          with
1>          [
1>              _Elem=char,
1>              _Traits=std::char_traits<char>,
1>              _Ax=std::allocator<char>
1>          ]
1>          c:\program files\microsoft visual studio 10.0\vc\include\ostream(898) : see declaration of 'std::operator <<'
1>c:\documents and settings\dell\my documents\visual studio 2010\projects\genome\genome\genome.cpp(34): error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,_Elem)' : could not deduce template argument for 'std::basic_ostream<_Elem,_Traits> &' from 'std::basic_string<_Elem,_Traits,_Ax>'
1>          with
1>          [
1>              _Elem=char,
1>              _Traits=std::char_traits<char>,
1>              _Ax=std::allocator<char>
1>          ]
1>          c:\program files\microsoft visual studio 10.0\vc\include\ostream(898) : see declaration of 'std::operator <<'
1>c:\documents and settings\dell\my documents\visual studio 2010\projects\genome\genome\genome.cpp(34): error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,const _Elem *)' : could not deduce template argument for 'std::basic_ostream<_Elem,_Traits> &' from 'std::basic_string<_Elem,_Traits,_Ax>'
1>          with
1>          [
1>              _Elem=char,
1>              _Traits=std::char_traits<char>,
1>              _Ax=std::allocator<char>
1>          ]
1>          c:\program files\microsoft visual studio 10.0\vc\include\ostream(851) : see declaration of 'std::operator <<'
1>c:\documents and settings\dell\my documents\visual studio 2010\projects\genome\genome\genome.cpp(34): error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,const _Elem *)' : could not deduce template argument for 'std::basic_ostream<_Elem,_Traits> &' from 'std::basic_string<_Elem,_Traits,_Ax>'
1>          with
1>          [
1>              _Elem=char,
1>              _Traits=std::char_traits<char>,
1>              _Ax=std::allocator<char>
1>          ]
1>          c:\program files\microsoft visual studio 10.0\vc\include\ostream(851) : see declaration of 'std::operator <<'
1>c:\documents and settings\dell\my documents\visual studio 2010\projects\genome\genome\genome.cpp(34): error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,const _Elem *)' : could not deduce template argument for 'std::basic_ostream<_Elem,_Traits> &' from 'std::basic_string<_Elem,_Traits,_Ax>'
1>          with
1>          [
1>              _Elem=char,
1>              _Traits=std::char_traits<char>,
1>              _Ax=std::allocator<char>
1>          ]
1>          c:\program files\microsoft visual studio 10.0\vc\include\ostream(851) : see declaration of 'std::operator <<'
1>c:\documents and settings\dell\my documents\visual studio 2010\projects\genome\genome\genome.cpp(34): error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,char)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'std::basic_string<_Elem,_Traits,_Ax>'
1>          with
1>          [
1>              _Elem=char,
1>              _Traits=std::char_traits<char>,
1>              _Ax=std::allocator<char>
1>          ]
1>          c:\program files\microsoft visual studio 10.0\vc\include\ostream(811) : see declaration of 'std::operator <<'
1>c:\documents and settings\dell\my documents\visual studio 2010\projects\genome\genome\genome.cpp(34): error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,char)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'std::basic_string<_Elem,_Traits,_Ax>'
1>          with
1>          [
1>              _Elem=char,
1>              _Traits=std::char_traits<char>,
1>              _Ax=std::allocator<char>
1>          ]
1>          c:\program files\microsoft visual studio 10.0\vc\include\ostream(811) : see declaration of 'std::operator <<'
1>c:\documents and settings\dell\my documents\visual studio 2010\projects\genome\genome\genome.cpp(34): error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,char)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'std::basic_string<_Elem,_Traits,_Ax>'
1>          with
1>          [
1>              _Elem=char,
1>              _Traits=std::char_traits<char>,
1>              _Ax=std::allocator<char>
1>          ]
1>          c:\program files\microsoft visual studio 10.0\vc\include\ostream(811) : see declaration of 'std::operator <<'
1>c:\documents and settings\dell\my documents\visual studio 2010\projects\genome\genome\genome.cpp(34): error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,const char *)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'std::basic_string<_Elem,_Traits,_Ax>'
1>          with
1>          [
1>              _Elem=char,
1>              _Traits=std::char_traits<char>,
1>              _Ax=std::allocator<char>
1>          ]
1>          c:\program files\microsoft visual studio 10.0\vc\include\ostream(764) : see declaration of 'std::operator <<'
1>c:\documents and settings\dell\my documents\visual studio 2010\projects\genome\genome\genome.cpp(34): error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,const char *)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'std::basic_string<_Elem,_Traits,_Ax>'
1>          with
1>          [
1>              _Elem=char,
1>              _Traits=std::char_traits<char>,
1>              _Ax=std::allocator<char>
1>          ]
1>          c:\program files\microsoft visual studio 10.0\vc\include\ostream(764) : see declaration of 'std::operator <<'
1>c:\documents and settings\dell\my documents\visual studio 2010\projects\genome\genome\genome.cpp(34): error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,const char *)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'std::basic_string<_Elem,_Traits,_Ax>'
1>          with
1>          [
1>              _Elem=char,
1>              _Traits=std::char_traits<char>,
1>              _Ax=std::allocator<char>
1>          ]
1>          c:\program files\microsoft visual studio 10.0\vc\include\ostream(764) : see declaration of 'std::operator <<'
1>c:\documents and settings\dell\my documents\visual studio 2010\projects\genome\genome\genome.cpp(34): error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,char)' : could not deduce template argument for 'std::basic_ostream<_Elem,_Traits> &' from 'std::basic_string<_Elem,_Traits,_Ax>'
1>          with
1>          [
1>              _Elem=char,
1>              _Traits=std::char_traits<char>,
1>              _Ax=std::allocator<char>
1>          ]
1>          c:\program files\microsoft visual studio 10.0\vc\include\ostream(726) : see declaration of 'std::operator <<'
1>c:\documents and settings\dell\my documents\visual studio 2010\projects\genome\genome\genome.cpp(34): error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,char)' : could not deduce template argument for 'std::basic_ostream<_Elem,_Traits> &' from 'std::basic_string<_Elem,_Traits,_Ax>'
1>          with
1>          [
1>              _Elem=char,
1>              _Traits=std::char_traits<char>,
1>              _Ax=std::allocator<char>
1>          ]
1>          c:\program files\microsoft visual studio 10.0\vc\include\ostream(726) : see declaration of 'std::operator <<'
1>c:\documents and settings\dell\my documents\visual studio 2010\projects\genome\genome\genome.cpp(34): error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,char)' : could not deduce template argument for 'std::basic_ostream<_Elem,_Traits> &' from 'std::basic_string<_Elem,_Traits,_Ax>'
1>          with
1>          [
1>              _Elem=char,
1>              _Traits=std::char_traits<char>,
1>              _Ax=std::allocator<char>
1>          ]
1>          c:\program files\microsoft visual studio 10.0\vc\include\ostream(726) : see declaration of 'std::operator <<'
1>c:\documents and settings\dell\my documents\visual studio 2010\projects\genome\genome\genome.cpp(34): error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,const char *)' : could not deduce template argument for 'std::basic_ostream<_Elem,_Traits> &' from 'std::basic_string<_Elem,_Traits,_Ax>'
1>          with
1>          [
1>              _Elem=char,
1>              _Traits=std::char_traits<char>,
1>              _Ax=std::allocator<char>
1>          ]
1>          c:\program files\microsoft visual studio 10.0\vc\include\ostream(679) : see declaration of 'std::operator <<'
1>c:\documents and settings\dell\my documents\visual studio 2010\projects\genome\genome\genome.cpp(34): error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,const char *)' : could not deduce template argument for 'std::basic_ostream<_Elem,_Traits> &' from 'std::basic_string<_Elem,_Traits,_Ax>'
1>          with
1>          [
1>              _Elem=char,
1>              _Traits=std::char_traits<char>,
1>              _Ax=std::allocator<char>
1>          ]
1>          c:\program files\microsoft visual studio 10.0\vc\include\ostream(679) : see declaration of 'std::operator <<'
1>c:\documents and settings\dell\my documents\visual studio 2010\projects\genome\genome\genome.cpp(34): error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,const char *)' : could not deduce template argument for 'std::basic_ostream<_Elem,_Traits> &' from 'std::basic_string<_Elem,_Traits,_Ax>'
1>          with
1>          [
1>              _Elem=char,
1>              _Traits=std::char_traits<char>,
1>              _Ax=std::allocator<char>
1>          ]
1>          c:\program files\microsoft visual studio 10.0\vc\include\ostream(679) : see declaration of 'std::operator <<'
1>c:\documents and settings\dell\my documents\visual studio 2010\projects\genome\genome\genome.cpp(34): error C2676: binary '<<' : 'std::basic_string<_Elem,_Traits,_Ax>' does not define this operator or a conversion to a type acceptable to the predefined operator
1>          with
1>          [
1>              _Elem=char,
1>              _Traits=std::char_traits<char>,
1>              _Ax=std::allocator<char>
1>          ]
1>c:\documents and settings\dell\my documents\visual studio 2010    1>
1>Time Elapsed 00:00:01.14
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
  • 0
    if((currentGene.length() % 3) == 0) не должен содержать конечную точку с запятой (если только вы действительно не хотите, чтобы следующий блок выполнялся каждый раз).
  • 0
    спасибо Johnsyweb
Показать ещё 3 комментария
Теги:
class
string
function

1 ответ

3

Добавить string:: before npos

if(genome.find("ATG",0) == string::npos)
                           ^^^^^^^^

Удалить << endl из этой строки кода

string currentGene = genome.substr(startGene + 3, endGene - (startGene +3)) <<endl;
                                                              DELETE THIS   ^^^^^^

Удалить ; с конца оператора if

if((currentGene.length() % 3) == 0);
                      DELETE THIS  ^

Это просто детали, но, как я уверен, вы понимаете, что важно при программировании.

  • 0
    спасибо, что получил большинство сообщений об ошибках, но теперь я получаю
  • 0
    Большое спасибо Джон
Показать ещё 3 комментария

Ещё вопросы

Сообщество Overcoder
Наверх
Меню