#include <iostream.h>
#include <fstream.h>
using namespace std;
struct SWords{
char [1];
};
class CDatabase{
protected:
SWords Word1[25];
SWords Word2[25];
static int numdatabases; //Keeps count of number of databses
public:
CDatabase() {numdatabases++;} // constructor
void GetWord(int) const; //Returns the word and meaning at the place(int) designated
void SetWord(int, SWords, SWords); //Sets the word at (int (position), as (char), meaning (char))
static int ReturnNum();
};
void CDatabase::GetWord(int a) const{
cout << Word1[a] << "means: " << Word2[a] <<endl;
}
void CDatabase::SetWord(int a, SWords b, SWords c){
this->Word1[a] = b;
this->Word2[a] = c;
}
static int CDatabase::ReturnNum(){
return numdatabases;
}
int main(int argc, char* argv)
{
CDatabase Data;
Data.SetWord(3,"H","E");
Data.GetWord(3);
cin.get();
}
I could use some help with my "translator"(array accessing f.ex))
Hello, and thanks for taking time.
I have thought for some time now to make an english-norwegian "translation database". And I just started out.
And the problems stack up too.
I do this in XCode on a MAC OS X. Thats why I dont use STL.
So if you guys could look over my code and state what problems there might be. Because I don't understand a bit about the compile-errors returned by XCode.
EDIT: Xcode wont let me copy the error messages
EDIT2: I'm sure it has something to do with my project type choices. I can't seem to figure out what type of project I need in order to compile a simple C++ program. Can someone just copy/paste the following code into a project and see if it works or if it gives weird error messages? Thank you very much!
Thanks in advance!
[Edited by - Samsonite on December 3, 2005 1:57:21 PM]
You haven't asked a question, so it's hard to say what you need help with. Can you be more specific about the nature of your problem?
// a void functionconst void CDatabase::GetWord(int a){ cout << Word1[a] << "means: " << Word2[a]<<endl;}// a while later...cout << data.GetWord(3) << endl
You can't cout the return value of a function if it doesn't return anything, 'course.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement