Pointers question

Started by
1 comment, last by bobbinus 18 years ago
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;
Advertisement
change the third line from:

*ppf = pf

to

ppf = &pf
Well done, thanks a lot mate....I must be way too tired...end of day time to have a rest :)

This topic is closed to new replies.

Advertisement