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

Started by
3 comments, last by Samsonite 18 years, 4 months ago
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{
	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();
}
	
			  
			


Thanks in advance! [Edited by - Samsonite on December 3, 2005 1:57:21 PM]
Hope I was helpful. And thank you if you were!
Advertisement
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?
- k2"Choose a job you love, and you'll never have to work a day in your life." — Confucius"Logic will get you from A to B. Imagination will get you everywhere." — Albert Einstein"Money is the most egalitarian force in society. It confers power on whoever holds it." — Roger Starr{General Programming Forum FAQ} | {Blog/Journal} | {[email=kkaitan at gmail dot com]e-mail me[/email]} | {excellent webhosting}
Yeah, I kinda forgot that [smile]
Hope I was helpful. And thank you if you were!
// 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.
It only takes one mistake to wake up dead the next morning.
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...

Hope I was helpful. And thank you if you were!

This topic is closed to new replies.

Advertisement