Hi All,
In C++ , if a function or class is declared friend, then where is that
information stored? How does friend function get access to private
data of a Class?
Thanks 6 1558
* Sunny:
Hi All,
In C++ , if a function or class is declared friend, then where is that
information stored? How does friend function get access to private
data of a Class?
C++ friendship is all at compile time: it tells the compiler what access
is allowed. There is no effect at run time. No information is stored
in the program or by the program; it's all in the compiler's mind, so to
speak.
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Hi,,
How does a Class Come to Known that it has Given Access to Private
Member variable's ------>to Group Certain Class's ?
what action it Need to Take when Other Non friend Class Access Its
variable ??
i want Explanation in term of Symbol Table
Thanks
Pallav
Alf P. Steinbach wrote:
* Sunny:
Hi All,
In C++ , if a function or class is declared friend, then where is that
information stored? How does friend function get access to private
data of a Class?
C++ friendship is all at compile time: it tells the compiler what access
is allowed. There is no effect at run time. No information is stored
in the program or by the program; it's all in the compiler's mind, so to
speak.
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
* Pallav singh:
Hi,,
How does a Class Come to Known that it has Given Access to Private
Member variable's ------>to Group Certain Class's ?
what action it Need to Take when Other Non friend Class Access Its
variable ??
i want Explanation in term of Symbol Table
Thanks
Pallav
Alf P. Steinbach wrote:
>* Sunny:
>>Hi All, In C++ , if a function or class is declared friend, then where is that information stored? How does friend function get access to private data of a Class?
C++ friendship is all at compile time: it tells the compiler what access is allowed. There is no effect at run time. No information is stored in the program or by the program; it's all in the compiler's mind, so to speak.
-- A: Because it messes up the order in which people normally read text. Q: Why is it such a bad thing? A: Top-posting. Q: What is the most annoying thing on usenet and in e-mail?
Read the FAQ. Especially the sections about how to post.
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
On 2007-04-30 13:16, Pallav singh wrote:
Alf P. Steinbach wrote:
>* Sunny:
>>Hi All, In C++ , if a function or class is declared friend, then where is that information stored? How does friend function get access to private data of a Class?
C++ friendship is all at compile time: it tells the compiler what access is allowed. There is no effect at run time. No information is stored in the program or by the program; it's all in the compiler's mind, so to speak.
How does a Class Come to Known that it has Given Access to Private
Member variable's ------>to Group Certain Class's ?
what action it Need to Take when Other Non friend Class Access Its
variable ??
I'm not quite sure what you are asking about, but given the context of
the thread you are posting in I guess that what you are asking is how
information about access to members (private/protected/public) are
stored and enforced in the application. If this is not your question
then please clarify.
The answer is that such information is not stored in the application
itself, it's only used by the compiler while parsing the code. While
parsing the code it checks so that you only access private members from
within the class or from friends and so on. If you violate any of those
rules it generates an error and does not produce any executable. So the
access specifiers are purely compile-time constructs.
--
Erik Wikström
Sunny skrev:
Hi All,
In C++ , if a function or class is declared friend, then where is that
information stored? How does friend function get access to private
data of a Class?
Thanks
Compiler magic.
--
OU
Pallav singh wrote:
How does a Class Come to Known that it has Given Access to Private
Member variable's
How does a class know that it cannot access a variable with a
certain name of another class? How does it know if that variable
even exists?
If the compiler can give you an error if some code tries to
access the private member of another class, why wouldn't it be
anything else than completely trivial for the compiler to see
that the class is actually saying that the code is allowed to
access it? This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Alexander Stippler |
last post by:
Hi
what's wrong about the following code? It does not compile.
template <typename T>
class A {
public:
class B;
};
|
by: Christophe Barbe |
last post by:
I posted a few days ago about the same problem but was not very clear. So
here is my second take at it.
Basically with GCC 3.3.2, I can't compile the example from the
C++ FAQ Lite available online at
http://www.parashift.com/c++-faq-lite/containers-and-templates.html#faq-34.15
Below are the two files that I compile with
g++ foo.cpp -o foo
or
|
by: Trevor Lango |
last post by:
What is the appropriate syntax for placing a friend function that includes
as one of it's parameters a pointer to the class object itself within the
template class?
I have the following:
//****************************************************
// testClass.h
//****************************************************
#ifndef TESTCLASS_H
|
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 private. I have placed "friend
void CA::Run_A(void)" in CMain Class. CMain::Run() function attempts to
execute CA::Run_A(), but compiler shows an error saying that it is the
violation to access private function.
I don't understand why because friend...
|
by: Samee Zahur |
last post by:
Question: How do friend functions and static member functions differ in
terms of functionality? I mean, neither necessarily needs an object of
the class to be created before they are called and either has access
only to static members of the class (ie. assuming no object of the
class is in scope - neither by arguments recieved nor by local
declarations). Any static member function like this:
//accessing static member i
static void...
| |
by: Mark P |
last post by:
Is this legal and sensible?
class Outer
{
friend struct Inner
{
...
};
...
|
by: freegnu |
last post by:
how to declare a friend function that can access two class
it will look like the following
class A
{
private:
int i;
public:
A(){}
~A(){}
friend void call(A &a, B &b);
|
by: WaterWalk |
last post by:
I find friend declaration just very tricky. I tried the following
examples on both MingW(gcc 3.4.2) and VC++ 2005. The results are
surprising.
Example1:
namespace ns1
{
class Test
{
friend void func()
|
by: SteveGod |
last post by:
Hi,
I'm trying to create a report that will produce automated sets of Committee Minutes for School Appeals, where there are a set range of different outcomes.
The field involved are all from the same table, and called:
, , , and
In the query where the result of the outcome in needed, it has the following in a field:
Minute: MINUTEOUTCOME(,,,,)
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |