Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2007-03-22
4
Medium Priority
?
233 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 250 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

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

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
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.
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

688 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