C++ c++;对Code::morsecode()的未定义引用和对Code::alphacode()的未定义引用

C++ c++;对Code::morsecode()的未定义引用和对Code::alphacode()的未定义引用,c++,C++,获取此错误 对代码::morsecode()的未定义引用 对代码::alphacode()的未定义引用 collect2:错误:ld返回了1个退出状态 使用C++ MySeCoE.CPP编译。我想不出问题出在哪里??我试图查看我的代码,看看问题出在哪里,但我无法找出问题所在。 感谢您的帮助。谢谢 #include <string> #include <vector> #include <iostream> using namespace std; clas

获取此错误 对代码::morsecode()的未定义引用 对代码::alphacode()的未定义引用 collect2:错误:ld返回了1个退出状态

使用C++ MySeCoE.CPP编译。我想不出问题出在哪里??我试图查看我的代码,看看问题出在哪里,但我无法找出问题所在。 感谢您的帮助。谢谢

#include <string>
#include <vector>
#include <iostream>

using namespace std;

class Code
{
public:
Code();         //Default Constructor

string decode(vector<string> message);  //Decodes message
private:
vector<string> codewords;   //codeword vector parallel to A-Z

vector<char> alpha;     //this is the vector for A-Z    

vector<char> alphacode();   //Function that builds the vector alpha -A B C...

vector<string> morsecode(); //function builds the vector codewords containing                         morsecode

char decode(string c);      //returns the character for the codeword c.
};

Code::Code()
{
codewords = morsecode();
alpha = alphacode();
}

string Code::decode(vector<string> message)
{
string temp;
for(int i = 0; i < message.size(); i++)
{
  temp += decode(message[i]);
}   
return temp;
}

char Code::decode(string c)
{
for(int i = 0; i < alpha.size(); i++)
{
  if(c == codewords[i])
  {
    return alpha[i];
  }
}
}



// This function returns a vector containing the morse code
vector<string> morsecode()
{ 
 vector<string> temp(28);
 temp[0] =".-";
 temp[1] ="-...";
 temp[2] ="-.-.";
 temp[3] ="-..";
 temp[4] =".";
 temp[5] ="..-.";
 temp[6] ="--.";
 temp[7] ="....";
 temp[8] ="..";
 temp[9] =".---";
 temp[10] ="-.-";
 temp[11] =".-..";
 temp[12] ="--";
 temp[13] ="-.";
 temp[14] ="---";
 temp[15] =".--.";
 temp[16] ="--.--";
 temp[17] =".-.";
 temp[18] ="...";
 temp[19] ="-";
 temp[20] ="..-";
 temp[21] ="...-";
 temp[22] =".--";
 temp[23] ="-..-";
 temp[24] ="-.--";
 temp[25] ="--..";
 temp[26] =".......";
 temp[27] ="x";
 return temp;
}

// This returns a vector containing the alphabet a-z and " "
vector<char> alphacode()
{
 vector<char> temp;
 for (char c='A'; c<='Z'; c++)
  temp.push_back(c);
  temp.push_back(' ');
  temp.push_back('.');
 return temp;
}

//Main Program
int main()
{
vector<string> message;
string temp;
Code c;

cin >> temp;

while (cin.good())
{
  message.push_back(temp);
  cin >> temp;
}

cout << c.decode(message) << endl;

return 0;
}
#包括
#包括
#包括
使用名称空间std;
类别代码
{
公众:
Code();//默认构造函数
字符串解码(矢量消息);//解码消息
私人:
向量码字;//与A-Z平行的码字向量
向量alpha;//这是A-Z的向量
向量alphacode();//构建向量alpha-A B C的函数。。。
vector morsecode();//函数生成包含morsecode的向量码字
char decode(字符串c);//返回码字c的字符。
};
代码::代码()
{
码字=莫尔斯电码();
alpha=字母代码();
}
字符串代码::解码(向量消息)
{
字符串温度;
对于(int i=0;itemp;
while(cin.good())
{
消息。推回(临时);
cin>>温度;
}

cout定义的独立函数
vector morsecode()
不是所需的
vector code::morsecode()

可能与Wow重复谢谢!!我确实参考了他们建议的上述链接,但我仍然无法理解编译器想要什么。谢谢你指出!!