• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

VC++ Templating a BST - Strings...

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...
 
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
 
Back
Top