Vector of structs

Hey I'm pretty new to C++ but have quite a bit of experience in Java. I have a project to make a Morse code translator. I have a struct that holds a letter and its morse code equivalent. Then I have a vector of these structs to hold all of the combinations. Here's the code thats giving me problems.

1
2
3
4
5
struct Code{
		string letter;
		string morse; 
	};
	vector<Code>* myConvertorTable;


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
void MorseCodeTranslator::setupConvertorTable()
{
	ifstream ifstr(myConversionTableFile.c_str());
	if(!ifstr)
	{
		cerr << "Cannot open: " << myConversionTableFile << "." << endl;
		exit(ERROR);	    
	}

  string tempLetter;
  string tempMorse;

  while(getline(ifstr, tempLetter))
  {
	myConvertorTable->letter.push_back(tempLetter);
	if(getline(ifstr, tempMorse))
	{
		myConvertorTable->morse.push_back(tempMorse);
	}
  }

#ifdef DEBUG
  for(int i = 0; i < myConvertorTable->size(); i++)
  {
	  cout << "morse: " << myConvertorTable->morse->at(i) << endl;
	  cout << "letter: " << myConvertorTable->letter->at(i) << endl;
  }
#endif

}



Heres the error messages.

MorseCodeTranslator.cpp: In member function âvoid MorseCodeTranslator::setupConvertorTable()â:
MorseCodeTranslator.cpp:19: error: âclass std::vector<MorseCodeTranslator::Code, std::allocator<MorseCodeTranslator::Code> >â has no member named âletterâ
MorseCodeTranslator.cpp:22: error: âclass std::vector<MorseCodeTranslator::Code, std::allocator<MorseCodeTranslator::Code> >â has no member named âmorseâ

Topic archived. No new replies allowed.