Getting Error when passing by reference

I'm trying to pass in vector<LeafNode*> LeafNodeList;
by reference into a class like this:
TreeFromListConstruction tree(&LeafNodeList);
why can't I do it? It says this:
: error C2664: 'TreeFromListConstruction::TreeFromListConstruction(std::vector<_Ty> *)' : cannot convert parameter 1 from 'std::vector<_Ty> *' to 'std::vector<_Ty> *'

1
2
3
4
5
6
7
8
9
10
11
12
13
//TreeFromListConstruction.h
...
#include "LeafNode.h"

class TreeFromListConstruction
{
public:
	TreeFromListConstruction(vector<Node*> *list);
private:
	vector<Node*> *itsList;

};
...


1
2
3
4
5
6
7
//TreeFromListConstruction.cpp
#include "TreeFromListConstruction.h"

TreeFromListConstruction::TreeFromListConstruction(vector<Node*> *list)
{
	itsList = list;
}

1
2
3
4
5
6
7
8
9
10
//main.cpp
...
vector<LeafNode*> LeafNodeList;
...
for(unsigned int i = 0; i < charByte.size(); i++)//putting the data into a LeafNode and the LeafNode into a list
	{
		LeafNodeList.push_back(new LeafNode(charByte[i], frequency[i]));
	}

	TreeFromListConstruction tree(&LeafNodeList);//***GET ERROR HERE*** 


Note LeafNode is a derived class of Node
Last edited on
vector<Node*> and vector<LeafNode*> are two different types. Try using a vector<Node*> to store your LeafNode ponters.
Thank you!
Topic archived. No new replies allowed.