Jump to content
  • Advertisement
Sign in to follow this  
Samsonite

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

This topic is 4642 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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{
	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]

Share this post


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

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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!