Question: INSTRUCTIONS: MESSAGE 1 : -.. --- -. - ....... ..-. --- .-. --. . - ....... - --- ....... -.. .-. .. -. -.- .......
INSTRUCTIONS:

MESSAGE 1 : -.. --- -. - ....... ..-. --- .-. --. . - ....... - --- ....... -.. .-. .. -. -.- ....... -.-- --- ..- .-. ....... --- ...- .- .-.. - .. -. . x MESSAGE 2 : .-- --- ..- -. -.. ... ....... -- -.-- ....... .... . .- .-. - ....... .-- .. - .... ....... .- ....... -- --- -. --- - --- -. --- ..- ... ....... .-.. .- -. --. --- ..- .-. x
=============================================================================================
BELOW IS MY CODE BUT I CANNOT GET IT TO COMPILE PLEASE HELP!!
=============================================================================================
#include #include #include
using namespace std;
class Code { public: Code(); // Default constructor - loads and uses morse code
string decode(vector message); // decodes a message
private:
vector codewords; // this is a codeword vector parallel to A-Z vector alpha; // this is the vector for A-Z
vector alphacode(); // function builds the vector alpha - A B C etc.
vector morsecode(); // function builds the vector codewords containing morse code
char decode(string c); //returns the character for the codeword c.
}; Code::Code() { alpha = alphacode(); codewords = morsecode(); } vector Code :: morsecode() { // This function returns a vector containing the morse code vector 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; } vector Code:: alphacode() {// This returns a vector containing the alphabet a-z and " " vector temp; for (char c='A'; c char Code::decode (string c) { for( int i = 0; i message) { string str= " "; for (int i=0; i int main ()
{ string filename; cout> filename;
ifstream ifs (filename.c_str()); if(!ifs.is_open()) { cout message; string c; cin>>c;
while (c!=x) { message.pushback(c); cin>>c; if (message=="x") { cout
message.pushback(x);
}
Your program should include the following functions: class Code public Code); 11 Default constructor - loads and uses morse code string decode (vectors string> message); // decodes a message private: vector codewords; // this is a codeword vector parallel to A-Z vector alpha; // this is the vector for A-Z vector char alphacode); I/ function builds the vector alpha A BC etc. vectorsstring> morsecode) // function builds the vector codewords containing morse code char decode(string c): //returns the character for the codeword c Your main program will use the above class to input a morse code message from a file. Since every codeword is separated by a space, you can input the message using cin, and store each codeword as a separate string in a vector Then submit the vector to the class function decode, and it will return the decoded message. When finished, output the string. You can download the functions morsecode and alphacode. Use your program to decode the messages message 1 and message 2