Hi all, ok so i am to create a wordpuzzle and with 3 classes..letterreplacement, letterremoval,vowel removal.

now for the letterreplacement am to replace all the occurence of a letter in a sentence with another letter. for the vowelremoval, am to removel the vowels in the sentence without leaving spaces and for the letterremoval, am to remove the letter occuring in a sentence with blank spaces.So i did a lil coding and i know am definitely missing some syntax,also having issues incoperating the menu, am new to c++, so much assistance would be appreciated.
wordpuzzle.cpp
Code:
#include <iostream>
#include <cstring>
#include "wordpuzzle.h"
#include <fstream>


using namespace std;


wordpuzzle::wordpuzzle()
{
string word, modified = "";
char search, replace;
bool check;
char letterarray[]; //icomplete type is not allowed

void displaymodified()
{
for (int i = 0; i < letterarray; i++)
{
modified = modified + 1
}
Print modified;
}

string compare()
{

}

void getletterarray()
{
strcpy(letterarray, word.c_str());
}
}


wordpuzzle::~wordpuzzle()
{
}



class LetterReplacement : public wordpuzzle //wordpuzzle says invalid base class
{
getletterarray(); //explicit type is missing(int assumed}- error

void replaceletter()
{
loop:letterarray[]; //letterarray is underfined- error
if (letterarray[i] == search) // search is underfined-error
letterarray[i] = replace; // replace is underfined-error
}
displaymodified(); //explicit type is missing(int assumed}- error
};


class VowelRemoval :public wordpuzzle
{
char vowelarray[5] = { a, e, i, o, u };
getletterarray; //this declaration has no storage class or type specifier

void removevowel()
{

loop:letterarray[] //letterarray is underfined-error
loop : vowelarray[]
if (letterarray[i] == vowelarray[i])
letterarray[i] = "";

displaymodified(); //displaymodified is undefined-error

}

};


class LetterRemoval : public wordpuzzle
{
getletterarray(); //explicit type is missing(int assumed}- error

void removeletter()
{
loop:letterarray[] //letterarray is underfined-error
if (letterarray[i] == search)
letterarray[i] = "";

displaymodified(); //displaymodified is undefined-error
}


};

wordpuzzle.h
class wordpuzzle
{
public:
wordpuzzle();
~wordpuzzle();


protected:
char search, replace;
char letterarray[];
void displaymodified();
void getletterarray();

};
main.cpp
#include <iostream>
#include <string>
#include <fstream>
#include "wordpuzzle.h"

using namespace std;

int main()
{
char search, replace;
char letterarray[100];
void displaymodified();
void getletterarray();
}


int menu()
{
int options;
cout << "1. Quit" << endl;
cout << "2. insert object" << endl;
cout << "3. Delele an object" << endl;
cout << "4. Edit" << endl;
cout << "5. Contents of display" << endl;
cout << "6. save to file" << endl;
cout << "7. load from file" << endl;
cout << "8. Answer" << endl;
cin >> options;
return options;
}

Last edited on
wordpuzzle.h
---------------
Line 10: You're declaring letterarray with no bounds. You must give it a size.

wordpuzzle.cpp
------------------
Lines 10-13: These declarations serve no purpose.

Line 13: You're trying to use lettterarray in your termination check. That won't work. You probably want the size of letterarray (which you haven;t defined).

Line 14: modified not defined. No ;

Lines 15,22,25: You're trying to nest functions within your constructor. You can't do that.

Line 16: Print modified makes no sense.

Line 19: compare is not a member function of wordpuzzle.

Line 31,56: You can't make a function call in a class declaration.

Line 34,59: loop: This is not a valid C++ construct.

Line 39: You're trying to strcpy into a zero sized array. Where is word defined?

Line 44: What is this?

Lines 49-50,60-61: i is not defined.

main.cpp
-----------
Line 13-14: These are function declarations, not function calls.

Line 18: menu() is never called.

Note: line numbers are approximate since you did not use code tags.

PLEASE USE CODE TAGS (the <> formatting button) when posting code.
It makes it easier to read your code and also easier to respond to your post.
http://www.cplusplus.com/articles/jEywvCM9/
Hint: You can edit your post, highlight your code and press the <> formatting button.
sorry new to this, also to c++ obviously seeing as my mistakes are many, actually implented pseudo-coding in this, forgive this noob... but if you where to create this word puzzle, how would you do it?
Topic archived. No new replies allowed.