Solved

Accessing a class private data members from a Form class in an MFC project

Posted on 2007-03-22
4
232 Views
Last Modified: 2013-11-26
Hello,
I have a class Form2 in my MFC project which is defined as :
class Dee_Form2 : public CDialog
{
    Load ld ;
// code for class' data and functions
}

I have another class called Load in the project which has prvate data and public member functions. I need to be able to acess most of the private data members of load through form 2 . I dont want to have to write a get member function to return a data member from the Load class. Whats the workaround?  
Thanks
-D
0
Comment
Question by:indacrypt
[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
  • 2
4 Comments
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 18772968
Have the members you need to access as public members.
0
 

Author Comment

by:indacrypt
ID: 18773574
no..that just defeats the purpose.....aah i think ill just have to write those get functions.
0
 
LVL 9

Accepted Solution

by:
smidgie82 earned 125 total points
ID: 18773584
Alternatively, declare class Form2 as a friend of class Load:

#include "form2.h"

class Load
{
    friend class Form2;

public:
.
.
.

private:
/* private data here */
}

Then any member of an instance of Form2 (or static members of Form2) should have access to the protected and private data and functional members of Load.
0
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 18773596
I don't think .net supports 'friend' classes.
0

Featured Post

Get MongoDB database support online, now!

At Percona’s web store you can order your MongoDB database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card. Handle your MongoDB database support now!

Question has a verified solution.

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

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
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.
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

635 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