Help with splitting class into 2, transferring member functions to new class

Hi

Can anyone guide me through copying some existing functions from my CD6WebWizardDlg class to my new CD6WebWizardData class I created using the class wizard (or whatever the equivalent is in VS 2003)? I've made all the member functions and variables of CD6WebWizardData public but when they are called from CD6WebWizardDlg the identifier is not found.

I've included "D6WebWizardData.h" in D6WebWizardDlg.cpp and D6WebWizard.cpp. I was expecting to just type "CD6WebWizardData->" and IntelliSense would show me the list of member functions and variables but it doesn't and expects ';' before '->'.

Any help would be appreciated. I've always had wizards to help me with classes so I've never really got to grips with them 100%.

Thanks,
Will
http://wjdashwood.co.uk/
wjdashwoodAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

AndyAinscowFreelance programmer / ConsultantCommented:
try
CD6WebWizardData data;
then
data.
to see if intellisense shows you the functions and variables

or the equivalent with a pointer to a CD6WebWizardData object
0
KurtVonCommented:
Shouldn't you be using a variable name for the pointer, not the class name?

CD6WebWizardData* pData;
pData = new CD6WebWizardData;
pData->MemberFunction();

Hope this helps.
0
AlexFMCommented:
You need to creare CD6WebWizardData instance or pointer:

CD6WebWizardData m_Data;
CD6WebWizardData m_pData;

Now when you type
p_Data.
or
m_pData->

you have IntelliSense list of class members.
0
Become a Certified Penetration Testing Engineer

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

AlexFMCommented:
Oops. Too late.
0
AndyAinscowFreelance programmer / ConsultantCommented:
To copy functions just use the editor.
I would suggest cuttin/pasting the contents from the cpp files first (so you can still double click on the class explorer view to spring to a function you haven't transferred) and then the appropriate lines in the .h files.
0
AndyAinscowFreelance programmer / ConsultantCommented:
Hi Alex
I'm getting faster at typing <grin>
0
wjdashwoodAuthor Commented:
Thanks guys! I deserve a good slap in the face for missing out on the very obvious! I'll get it working then come back and give out points.

Cheers,
Will
0
wjdashwoodAuthor Commented:
Perhaps not as plain sailing as I thought. The compiler doesn't like :

protected:
      CD6WebWizardData* pData;

error C2143: syntax error : missing ';' before '*'

Have I put it in the wrong place? Interestingly though, IntelliSense works!
0
AndyAinscowFreelance programmer / ConsultantCommented:
Have you included the .h file that has the CD6WebWizardData in it?

or in your header file near the top add the line
class CD6WebWizardData;
which is a forward declaration.
You would need the header included in your cpp file for the second way
0
KurtVonCommented:
Nope that happens when the object isn't defined.  Make sure you include D6WebWizrdData.h before D6WebWizardDlg.h.
0
KurtVonCommented:
Boy, you are getting fast at typing :-)
0
AndyAinscowFreelance programmer / ConsultantCommented:
Theres a lotta points here!  Good incentive!
0
wjdashwoodAuthor Commented:
Right, one problem down, another to go!

m_pData = new CD6WebWizardData;

error C2864: 'm_pData' : only const static integral data members can be initialized inside a class or struct
0
AndyAinscowFreelance programmer / ConsultantCommented:
Not in the header file.
in .h
CD6WebWizardData* m_pData;


in .cpp (eg constructor)
m_pData = new CD6WebWizardData;
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
wjdashwoodAuthor Commented:
Aha! Once again problem solved and all is right with the world. Thanks for all your help. Just for the record, which is best to do; create an instance or a pointer? What's the difference?
0
wjdashwoodAuthor Commented:
No one so keen on answering that one? Never mind, not important. I assume that creating a new instance makes a copy of the class instead of referring to the original. Now I have to try and share points out fairly! Eek.
0
AndyAinscowFreelance programmer / ConsultantCommented:
I've just been taking the kids out for a walk so didn't see the question.
'which is best to do; create an instance or a pointer? What's the difference? '

One is on the heap the other on the stack.  In the old days where memory was precious it could make quite a difference.  In reality for most situations now it probably doesn't make that much difference.  Having said that creating a pointer object with new requires you to delete it yourself so a bit of extra code to tidy up (and a not uncommon problem of invalid pointers when cleaned up too soon!).
0
wjdashwoodAuthor Commented:
I see, thanks for clearing that up for me. I assume I delete the pointer in the destructor of my CD6WebWizardDlg?

Cheers,
Will
0
AndyAinscowFreelance programmer / ConsultantCommented:
Thats a typical place to perform cleanup
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.