VC++ Templating a BST - Strings...

UsuLsuspct

Member
Aug 15, 2000
30
0
0
I am templating a BST (Binary Search Tree), and I was wondering if there is a way to include a string template? I cant seem to find a String library that is standard that works for me.

I thought maybe I could do it with stdlib and use std::string, but that isnt working for me? Is there another way to include strings?

What I am doing is making a templated BST and then the app will include a menu offering to create a BST containing either int's, float's, or strings...

I have it working fine for the int's and float's, and my teacher wants strings, but I am not sure how to do it, and he is a prick and wont offer ideas because it's homework to help us learn...
 

Adrian Tung

Golden Member
Oct 10, 1999
1,370
1
0
I am assuming that your BST stores pointers to the variables (int*, float*, etc) instead of actually storing the variable itself.

In this case, since you are using VC++, you could try using the MFC class CString, or write your own string class, or simply create a structure containing a variable of type char*.

Of the three, I'd recommend the second approach, as I am not sure how compatible CString will be for your BST, and for the last method you will have to manually delete the pointer on your own.


Hope that helps,
:)atwl