使用 C++ 字符串类函数从较长的原始基因组字符串进行"gene substrings"

using c++ string class functions to make "gene substrings" from a longer original Genome string

本文关键字:字符串 基因组 gene substrings 原始 类函数 C++ 使用      更新时间:2023-10-16

请帮助

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

我认为,它称npo为未经申报的身份识别者。我以为如果找不到ATG ,npos就会返回

这个有一个问题,我觉得很奇怪,因为当我没有把它放进变量currentGene中,只是把cout用于这个子字符串时,它就起作用了

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

上面写着

010projectsgenomegenomegenome.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 "Debuggenome.unsuccessfulbuild".
1>ClCompile:
1>  genome.cpp
1>c:documents and settingsdellmy documentsvisual studio 2010projectsgenomegenomegenome.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 filesmicrosoft visual studio 10.0vcincludestring(489) : see declaration of 'std::operator <<'
1>c:documents and settingsdellmy documentsvisual studio 2010projectsgenomegenomegenome.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 filesmicrosoft visual studio 10.0vcincludestring(489) : see declaration of 'std::operator <<'
1>c:documents and settingsdellmy documentsvisual studio 2010projectsgenomegenomegenome.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 filesmicrosoft visual studio 10.0vcincludestring(489) : see declaration of 'std::operator <<'
1>c:documents and settingsdellmy documentsvisual studio 2010projectsgenomegenomegenome.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 filesmicrosoft visual studio 10.0vcincludeostream(1085) : see declaration of 'std::operator <<'
1>c:documents and settingsdellmy documentsvisual studio 2010projectsgenomegenomegenome.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 filesmicrosoft visual studio 10.0vcincludeostream(1085) : see declaration of 'std::operator <<'
1>c:documents and settingsdellmy documentsvisual studio 2010projectsgenomegenomegenome.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 filesmicrosoft visual studio 10.0vcincludeostream(1085) : see declaration of 'std::operator <<'
1>c:documents and settingsdellmy documentsvisual studio 2010projectsgenomegenomegenome.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 filesmicrosoft visual studio 10.0vcincludeostream(968) : see declaration of 'std::operator <<'
1>c:documents and settingsdellmy documentsvisual studio 2010projectsgenomegenomegenome.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 filesmicrosoft visual studio 10.0vcincludeostream(968) : see declaration of 'std::operator <<'
1>c:documents and settingsdellmy documentsvisual studio 2010projectsgenomegenomegenome.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 filesmicrosoft visual studio 10.0vcincludeostream(968) : see declaration of 'std::operator <<'
1>c:documents and settingsdellmy documentsvisual studio 2010projectsgenomegenomegenome.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 filesmicrosoft visual studio 10.0vcincludeostream(958) : see declaration of 'std::operator <<'
1>c:documents and settingsdellmy documentsvisual studio 2010projectsgenomegenomegenome.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 filesmicrosoft visual studio 10.0vcincludeostream(958) : see declaration of 'std::operator <<'
1>c:documents and settingsdellmy documentsvisual studio 2010projectsgenomegenomegenome.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 filesmicrosoft visual studio 10.0vcincludeostream(958) : see declaration of 'std::operator <<'
1>c:documents and settingsdellmy documentsvisual studio 2010projectsgenomegenomegenome.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 filesmicrosoft visual studio 10.0vcincludeostream(951) : see declaration of 'std::operator <<'
1>c:documents and settingsdellmy documentsvisual studio 2010projectsgenomegenomegenome.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 filesmicrosoft visual studio 10.0vcincludeostream(951) : see declaration of 'std::operator <<'
1>c:documents and settingsdellmy documentsvisual studio 2010projectsgenomegenomegenome.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 filesmicrosoft visual studio 10.0vcincludeostream(951) : see declaration of 'std::operator <<'
1>c:documents and settingsdellmy documentsvisual studio 2010projectsgenomegenomegenome.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 filesmicrosoft visual studio 10.0vcincludeostream(944) : see declaration of 'std::operator <<'
1>c:documents and settingsdellmy documentsvisual studio 2010projectsgenomegenomegenome.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 filesmicrosoft visual studio 10.0vcincludeostream(944) : see declaration of 'std::operator <<'
1>c:documents and settingsdellmy documentsvisual studio 2010projectsgenomegenomegenome.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 filesmicrosoft visual studio 10.0vcincludeostream(944) : see declaration of 'std::operator <<'
1>c:documents and settingsdellmy documentsvisual studio 2010projectsgenomegenomegenome.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 filesmicrosoft visual studio 10.0vcincludeostream(937) : see declaration of 'std::operator <<'
1>c:documents and settingsdellmy documentsvisual studio 2010projectsgenomegenomegenome.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 filesmicrosoft visual studio 10.0vcincludeostream(937) : see declaration of 'std::operator <<'
1>c:documents and settingsdellmy documentsvisual studio 2010projectsgenomegenomegenome.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 filesmicrosoft visual studio 10.0vcincludeostream(937) : see declaration of 'std::operator <<'
1>c:documents and settingsdellmy documentsvisual studio 2010projectsgenomegenomegenome.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 filesmicrosoft visual studio 10.0vcincludeostream(898) : see declaration of 'std::operator <<'
1>c:documents and settingsdellmy documentsvisual studio 2010projectsgenomegenomegenome.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 filesmicrosoft visual studio 10.0vcincludeostream(898) : see declaration of 'std::operator <<'
1>c:documents and settingsdellmy documentsvisual studio 2010projectsgenomegenomegenome.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 filesmicrosoft visual studio 10.0vcincludeostream(898) : see declaration of 'std::operator <<'
1>c:documents and settingsdellmy documentsvisual studio 2010projectsgenomegenomegenome.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 filesmicrosoft visual studio 10.0vcincludeostream(851) : see declaration of 'std::operator <<'
1>c:documents and settingsdellmy documentsvisual studio 2010projectsgenomegenomegenome.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 filesmicrosoft visual studio 10.0vcincludeostream(851) : see declaration of 'std::operator <<'
1>c:documents and settingsdellmy documentsvisual studio 2010projectsgenomegenomegenome.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 filesmicrosoft visual studio 10.0vcincludeostream(851) : see declaration of 'std::operator <<'
1>c:documents and settingsdellmy documentsvisual studio 2010projectsgenomegenomegenome.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 filesmicrosoft visual studio 10.0vcincludeostream(811) : see declaration of 'std::operator <<'
1>c:documents and settingsdellmy documentsvisual studio 2010projectsgenomegenomegenome.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 filesmicrosoft visual studio 10.0vcincludeostream(811) : see declaration of 'std::operator <<'
1>c:documents and settingsdellmy documentsvisual studio 2010projectsgenomegenomegenome.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 filesmicrosoft visual studio 10.0vcincludeostream(811) : see declaration of 'std::operator <<'
1>c:documents and settingsdellmy documentsvisual studio 2010projectsgenomegenomegenome.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 filesmicrosoft visual studio 10.0vcincludeostream(764) : see declaration of 'std::operator <<'
1>c:documents and settingsdellmy documentsvisual studio 2010projectsgenomegenomegenome.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 filesmicrosoft visual studio 10.0vcincludeostream(764) : see declaration of 'std::operator <<'
1>c:documents and settingsdellmy documentsvisual studio 2010projectsgenomegenomegenome.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 filesmicrosoft visual studio 10.0vcincludeostream(764) : see declaration of 'std::operator <<'
1>c:documents and settingsdellmy documentsvisual studio 2010projectsgenomegenomegenome.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 filesmicrosoft visual studio 10.0vcincludeostream(726) : see declaration of 'std::operator <<'
1>c:documents and settingsdellmy documentsvisual studio 2010projectsgenomegenomegenome.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 filesmicrosoft visual studio 10.0vcincludeostream(726) : see declaration of 'std::operator <<'
1>c:documents and settingsdellmy documentsvisual studio 2010projectsgenomegenomegenome.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 filesmicrosoft visual studio 10.0vcincludeostream(726) : see declaration of 'std::operator <<'
1>c:documents and settingsdellmy documentsvisual studio 2010projectsgenomegenomegenome.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 filesmicrosoft visual studio 10.0vcincludeostream(679) : see declaration of 'std::operator <<'
1>c:documents and settingsdellmy documentsvisual studio 2010projectsgenomegenomegenome.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 filesmicrosoft visual studio 10.0vcincludeostream(679) : see declaration of 'std::operator <<'
1>c:documents and settingsdellmy documentsvisual studio 2010projectsgenomegenomegenome.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 filesmicrosoft visual studio 10.0vcincludeostream(679) : see declaration of 'std::operator <<'
1>c:documents and settingsdellmy documentsvisual studio 2010projectsgenomegenomegenome.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 settingsdellmy documentsvisual studio 2010    1>
1>Time Elapsed 00:00:01.14
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

npos 之前添加string::

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  ^

这只是细节,但我相信你在编程时会意识到细节很重要。