ScholarMatic | 24/7 Homework Help

ScholarMatic Will Help You Write Your Essays and Term Papers

Answered » You can buy a ready-made answer or pick a professional tutor to order an original one.

Why is this not compiling?

by | Nov 28, 2023 | engineering

Why is this not compiling? This is a C++ morse code decoder program. It has two errors. I have bolded and italicized the errors and messages.

#include <cstdlib>

#include <iostream>

#include <cassert>

struct TREENODE

{

char letter;

TREENODE *left;

TREENODE *right;

TREENODE() //constructor

{

letter = ‘*’; //will replace with letter

left = 0;

right = 0;

};

struct MORSECODE

//each morsecode object has english letters

{

char letter;

char code[20]; //dots and dashes and such

};

class TELEGRAPH //binary tree

{

private:

static MORSECODE table[40];

static TREENODE * root;

static void destroyTree(TREENODE *node);

public:

TELEGRAPH()

{

root = NULL;

} // expected unqualified-id at end of input. no return statement in function returning non-void (-Wreturn type)

static void buildTree();

static void destroyTree();

void Encode(char text[], char morse[]);

void Decode(char morse[], char text[]);

};

MORSECODE TELEGRAPH::table[40] = {{‘E’,”.”}, {‘T’, “-“}, {‘I’, “..”}, {‘A’, “.-“}, {‘N’, “-.”}, {‘M’, “–“},

{‘S’, “…”}, {‘U’, “..-“}, {‘R’, “.-.”}, {‘W’, “.–“}, {‘D’, “-..”}, {‘K’, “-.-“},

{‘G’, “–.”}, {‘O’, “—“}, {‘H’, “….”}, {‘V’, “…-“}, {‘F’, “..-.”}, {‘L’, “.-..”},

{‘P’, “.–.”}, {‘J’, “.—“}, {‘B’, “-…”}, {‘X’, “-..-“},

{‘C’, “-.-.”}, {‘Y’, “-.–“}, {‘Z’, “–..”}, {‘Q’, “–.-“}, {‘0’, “—–“}, {‘1’, “.—-“), {‘2’, “..—“},

{‘3’, “…–“}, {‘4’, “….-“}, {‘5’, “…..”}, {‘6’, “-….”}, {‘7’, “–…”}, {‘8’, “—..”}, {‘9’, “—-.”},

{‘,’, “—-“}, {‘.’, “.-.-.-“}, {‘?’, “..–..”}, {”, “END”};

TREENODE* TELEGRAPH::root = 0;

void TELEGRAPH::Decode(char morse[], char text[])

{

char *morsePtr;

TREENODE *node;

node = root;

cout << “Decode called.” << endl;

for (morsePtr = morse; *morsePtr; morsePtr++)

{

if (*morsePtr != ‘ ‘)

{

if (*morsePtr == ‘.’)

{

node = node >left;

}

else if (*morsePtr == ‘-‘)

{

nose = node >right;

}

}

else {

node = root;

}

continue;

}

*text++ = node-> letter;

return;

}

void TELEGRAPH::Encode(char text[], char morse[])

{

int i;

char c, *t, *morsePtr;

cout << “Encode called” << endl;

cout << “nSending >>> “;

for (t = text; *t; t++)

{

c = toupper(*t);

if (c == ‘ ‘)

{

*morse++ = ‘ ‘;

continue;

}

for (i = 0; table[i].letter; i++)

{

if (table[i].letter == c) break;

}

if (!table[i].letter)

{

continue;

}

morsePtr = table[i].code;

while (*morsePtr)

{

*morse++ = *morsePtr++;

}

*morse++ = ‘ ‘;

}

}

void TELEGRAPH::buildTree()

{

TREENODE *node, *nextNode;

char *morsePtr; // point to dots and dashes in table

root = new TREENODE;

if (!root)

{

return;

}

root -> letter = ‘ ‘;

cout << “Alphabet in Morse:”;

for (int i = 0; table[i].letter; i++)

{

node = root;

for (morsePtr = table[i].code; *morsePtr; morsePtr++)

//goes through morse code for symbols and letters

{

if (*morsePtr == ‘-‘)

{

cout << *morsePtr;

nextNode = new TREENODE;

node >right = nextNode;

node = node->right;

}

else if (*morsePtr == ‘.’)

{

cout << *morsePtr;

nextNode = new TREENODE;

node >left = nextNode;

node = node->left;

}

}

}

}

main():

int main()

{

TELEGRAPH station;

char text[80], morse[600];

station.buildTree();

cout << “Enter telegram in English: “;

cin.getline(text, 80);

station.Encode(text, morse);

cout << morse;

cout << ” >>> Receivednn”;

station.Decode(morse, text);

cout << “Message sent: ” << text << endl;

station.destroyTree();

} //expected ‘;’ at end of member declaration. expected ‘}’ at end of input. invalid use of qualified name TREEDNODE::TELEGRAPH::table

ScholarMatic: Explanation & Answer

Your ready answer from a verified tutor is just a click away for as little as $14.99


  

Click Order Now to get 100% Original Answer Customized to your instructions!

HOME TO CERTIFIED WRITERS

Why Place An Order With Us?

  • Certified Editors
  • 24/7 Customer Support
  • Profesional Research
  • Easy to Use System Interface
  • Student Friendly Pricing

Have a similar question?

PLAGIRAISM FREE PAPERS

All papers we provide are well-researched, properly formatted and cited.

TOP QUALITY

All papers we provide are well-researched, properly formatted and cited.

HIGHLY SECURED

All papers we provide are well-researched, properly formatted and cited.

ScholarMatic: Get Started

Assignment Writing Service

Feel safe and secure when placing an order on our portal!
Fruitful cooperation begins with solid guarantees, and we are professional enough to promise perfect results. Let’s get it started!