开发者

help with pointers and passing linked list as parameter, undefined reference c++

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 开发者_如何学JAVAtry 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.


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

Should be:

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜