Question: c++ templated and pointer function definition Question:How to define a templated and function that is a pointer to a struct inside the class? template <

c++ templated and pointer function definition

Question:How to define a templated and function that is a pointer to a struct inside the class?

template<typename theKey, typename theValue>

class BST

{

private:

struct node{

theKey key;

theValue value;

node* left;

node* right;

};

node* CreateLeaf(const theKey &x, const theValue &y);

public:

void insert(const theKey & x, const theValue & y);

};

//Now I want to defined the functions (particularly node* CreateLeaf(const theKey &x, const theValue &y); )

template<typename Key, typename Value>

BST< theKey, theValue>::node* BST::CreateLeaf(const theKey &k, const theValue &v){

//define function

}

//Okay so my problem is that somehow my compiler say "Missing 'typename' prior to dependent type name 'BST::node'

So what is wrong with this? What might be wrong with this?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!