Hiding pointers

Started by
2 comments, last by Splinter of Chaos 15 years, 4 months ago
Hello I'm developing a C++ "ResourceManagement" library as a part of an educational game engine. The library will develop as collection of classes Like: ResourceManager* rsm = NULL; Resource* rs = NULL; rs = rsm->Get_Mesh( "filename.x" , true ); As you can see in the sample code above , objects didn't allocate using "new" operator , and they also managed by "ResourceManager" class & mustn't be "delete". This is known that target users are not experienced in C++ programming , So I want to do some thing to hide pointers from them to not "new" or "Delete" objects & limit them to use the framework. How Can I do this? Do you suggest some "typedef" or what? please share your experiences with we. thanx
Advertisement
boost::shared_ptr (or anything that isn't C or C++)
Quote:Original post by Mehdi_H
This is known that target users are not experienced in C++ programming , So I want to do some thing to hide pointers from them to not "new" or "Delete" objects & limit them to use the framework.


Some random thoughts on your situation:

Have you considered using a scripting engine to expose this functionality to the end user? Using a scripting language would allow you to hide a lot of the tedious and advanced functionality of the C/C++ languages. Additionally, the end user would not be required to compile the source code in order to see their results. It could be as simple as them using notepad to create a few files that are saved into some specified folder. The CPython and Lua scripting engines (for example) provide a way for you embed them in your software. Additionally they also provide a way to expose your objects, functions, etc to the end user.

What is your target audience? How much experience with programming do they have? We would be able to make better suggestions if we knew.
Ever heard of RAII? Even professionals don't like dealing with pointers it seems.

BTW: What form of learning are you planning on offering? If these are simple beginning programmers, then I like the scripting idea. If you're using C++ because these programmers should be able to handle doing more low-level code, then why shield them from resource acquisition? Why not introduce them to it, or at least practice them in it?

I know they might leak resources, but you can also catch this and inform them of the problem! Or, let them make their own bed, afterwards forcing them to lay in it.

This topic is closed to new replies.

Advertisement