0

I am getting an error message that says undefined reference to

encrypt(int, std::list<int, std::allocator<int> >*)

Here is how I am trying to use it:

decka = new list<int>;
  ifstream inF;

  inF.open(filename.c_str());

  if (inF.fail()){
    cerr << "Error opening file" << endl;
    exit(1);
  }
  int deckcount = 28;
  int card;
  for(int i = 0; i != deckcount; i++){
    inF >> card;

    decka->push_back(card);
  }
  inF.close();

  if(eorD == "e")
    convertM(message);
    int esize = message.length();
    convertToNum(message);
    encrypt(esize, decka);
}

The error is coming from where I try and call encrypt.

Here is the encrypt function:

void encrypt(int msize, list<int> *L){

  int jokeA = 27;
  int jokeB = 28;

  list<int>::iterator a = std::find(L->begin(), L->end(), jokeA);
  list<int>::iterator new_position = a;
  for(int i=0; i < 1 && new_position != L->begin(); i++)
    new_position--;

  L->insert(new_position, 1, *a);

  L->erase(a);
}

And just so you can see how the class is defined here:

class DeckOps{
 public:
  DeckOps(string, string, string);
  ~DeckOps();
  string convertM(string);
  string convertToNum(string);
  void encrypt(int, list<int>*);

 private:

  list<int> *decka;

};

My goal here is to be able to access elements of decka using my encrypt function.

2
  • I can see nothing wrong with this code. What exactly is the line the error occurs? Commented May 21, 2011 at 20:33
  • Was the encrypt function defined like you have it here, without DeckOps::? Commented May 21, 2011 at 20:36

1 Answer 1

3
void encrypt(int msize, list<int> *L){

Should be:

void DeckOps::encrypt(int msize, list<int> *L){
Sign up to request clarification or add additional context in comments.

1 Comment

omg i am lame, i cant believe i did not see that! i guess im thinking a little too hard!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.