[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

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

Posted on 2003-11-14
19
Medium Priority
?
223 Views
Last Modified: 2013-11-20
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/
0
Comment
Question by:wjdashwood
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 6
  • 3
  • +1
19 Comments
 
LVL 45

Expert Comment

by:AndyAinscow
ID: 9747879
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
 
LVL 11

Expert Comment

by:KurtVon
ID: 9747884
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
 
LVL 48

Expert Comment

by:AlexFM
ID: 9747891
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
Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

 
LVL 48

Assisted Solution

by:AlexFM
AlexFM earned 400 total points
ID: 9747899
Oops. Too late.
0
 
LVL 45

Expert Comment

by:AndyAinscow
ID: 9747905
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
 
LVL 45

Expert Comment

by:AndyAinscow
ID: 9747915
Hi Alex
I'm getting faster at typing <grin>
0
 

Author Comment

by:wjdashwood
ID: 9747928
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
 

Author Comment

by:wjdashwood
ID: 9748006
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
 
LVL 45

Expert Comment

by:AndyAinscow
ID: 9748049
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
 
LVL 11

Expert Comment

by:KurtVon
ID: 9748061
Nope that happens when the object isn't defined.  Make sure you include D6WebWizrdData.h before D6WebWizardDlg.h.
0
 
LVL 11

Assisted Solution

by:KurtVon
KurtVon earned 800 total points
ID: 9748065
Boy, you are getting fast at typing :-)
0
 
LVL 45

Expert Comment

by:AndyAinscow
ID: 9748088
Theres a lotta points here!  Good incentive!
0
 

Author Comment

by:wjdashwood
ID: 9748141
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
 
LVL 45

Accepted Solution

by:
AndyAinscow earned 800 total points
ID: 9748165
Not in the header file.
in .h
CD6WebWizardData* m_pData;


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

Author Comment

by:wjdashwood
ID: 9748183
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
 

Author Comment

by:wjdashwood
ID: 9748334
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
 
LVL 45

Expert Comment

by:AndyAinscow
ID: 9748471
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
 

Author Comment

by:wjdashwood
ID: 9748598
I see, thanks for clearing that up for me. I assume I delete the pointer in the destructor of my CD6WebWizardDlg?

Cheers,
Will
0
 
LVL 45

Expert Comment

by:AndyAinscow
ID: 9748619
Thats a typical place to perform cleanup
0

Featured Post

Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question