Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design Application And Administration

Authors: Michael Mannino, Michael V. Mannino

2nd Edition

0072880678, 9780072880670

More Books

Students also viewed these Databases questions

Question

Show that P{Ta Answered: 1 week ago

Answered: 1 week ago

Question

Simplify each of the following Boolean equations

Answered: 1 week ago