Sign in to follow this  
bobbinus

Pointers question

Recommended Posts

Hello I have a function(belonging to ClassA). The functions purpose is to intialise a pointer to a ClassB. There are a few pointers belonging to ClassA that are of this type and all shall be initialised using this function. The function takes an enumeration and then uses a switch statement to intialise some function variables with the appropriate constants...the enumeration also indicates which member pointer should be initialised. So, I want to use a local function pointer to classB and create the new object and then set the appropriate memeber pointer to that object. To do all this I can use two switch statements: one at the start for the variables....and one at the end to set the member pointer to the local one. Can I just use one switch statement...at the start? At first I thought so but now maybe not. I thought make a pointer to pointer and use that to select the member pointer in the first swictch statement then indirectly initialise it...but it causes a memory crash...the following is representative of what I tried to do...3rd line causes a crash.... float** ppf = NULL; float* pf = NULL; *ppf = pf; *ppf = new float;

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this