473,473 Members | 1,730 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

access a private member function witout using a friend, virtual

1 New Member
hi,,,
i am having a scenario plz help me to find a soln,, its really challenging for me hope it is useful 4 u 2....

I need to access a private member function witout using a friend, virtual and not modifying the class,, for example consided this

class X
{
private:
void show() // this is the fn i need to access
public:
,,.........
........

};

you should not include anything inside the class X and u should access the funciton show()



Note: Plz dont say anything like # define private public
Jan 9 '07 #1
2 4149
Manjiri
40 New Member
hi,,,
i am having a scenario plz help me to find a soln,, its really challenging for me hope it is useful 4 u 2....

I need to access a private member function witout using a friend, virtual and not modifying the class,, for example consided this

class X
{
private:
void show() // this is the fn i need to access
public:
,,.........
........

};

you should not include anything inside the class X and u should access the funciton show()



Note: Plz dont say anything like # define private public

what those dots represents in public section....?
If you can include some functions in there then u can call from public member function na....
Jan 9 '07 #2
Ganon11
3,652 Recognized Expert Specialist
The only way you can access a private function is within the class itself - you will have to include a public function whose sole purpose is calling the private function.
Jan 9 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: David Rubin | last post by:
Is there ever a good reason to declare private non-virtual member functions in a class definition? As far as private virtual function are concerned, my understanding is that, if you have a...
11
by: Roger Leigh | last post by:
The C++ book I have to hand (Liberty and Horvath, Teach yourself C++ for Linux in 21 Days--I know there are better) states that "static member functions cannot access any non-static member...
12
by: Bryan Parkoff | last post by:
CMain Class is the base class that is initialized in main function. CA Class is the base class that is initialized in CMain::CMain(). CMain Class is always public while CA Class is always...
5
by: Morten Aune Lyrstad | last post by:
I am in the process of writing a virtual machine. I know that one should not give access to private variables in a class (by using friend) but wouldn't that speed up execution? Like this: class...
6
by: blueblueblue2005 | last post by:
here is a friend function of Class Array, which has two private data member: int size, int *ptr // Array's public member function to return size int getSize() const { return size; } friend...
6
by: Peter Frost | last post by:
Please help I don't know if this is possible but what I would really like to do is to use On Error Goto to capture the code that is being executed when an error occurs. Any help would be much...
3
by: Samuel Burri | last post by:
Hi there I got a simple problem. As you can see in the posted source, I have two classes, where one is derived from the other. In fact, they also contain virtual functions. In the function...
7
by: Valeriu Catina | last post by:
Hi, consider the Shape class from the FAQ: class Shape{ public: Shape(); virtual ~Shape(); virtual void draw() = 0;
1
by: Dan Smithers | last post by:
Can a make a private member function a friend? The code below suggests not. I am using g++ 4.2.3 I realise that I can make the whole CFriend class a friend, or make my friend function public but...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.