Sign in to follow this  

I could use some help with my "translator"(array accessing f.ex))

Recommended Posts

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!
#include <iostream.h>
#include <fstream.h>

using namespace std;

struct SWords{
	char [1];

class CDatabase{
			  SWords Word1[25];
			  SWords Word2[25];
			  static int numdatabases;			//Keeps count of number of databses
			  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;

Thanks in advance! [Edited by - Samsonite on December 3, 2005 1:57:21 PM]

Share this post

Link to post
Share on other sites
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?

Share this post

Link to post
Share on other sites

// a void function
const 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.

Share this post

Link to post
Share on other sites
Oh, stupid me. I made the "void" change when I understood that I couldn't use two-dimenional arrays(or atleast I thought so)

Lets see if it works now...

Seems, this might take a while.

I'll bring more info later...

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this