Questions tagged [friend-class]

In object-oriented programming to allow access to "private" or "protected" data of a class in another class, the latter class is declared as a friend class.

83 questions
0
votes
2 answers

Overloading an operator through friend function and returning a type different from the rhs parameters

I am attaching the code here and explaining the problem below: Here is the class Bitop: #ifndef _Bitop_H #define _Bitop_H # include double num2fxp(double v, int bits=9, int intbits=5){ return -0.5; } template
0
votes
5 answers

friend class declaration

i am new to c++ programming, can we declare some members of class as friend to other class. it means Lets say Class A have three member functions and instead of declaring whole class as friend to other Class B (say) can i declare only one…
nagaradderKantesh
  • 1,672
  • 4
  • 18
  • 30
-1
votes
2 answers

Why won't this code, implementing PassKey pattern, compile?

Here is the code, c++11 : #include #include template class Passkey { friend T; Passkey() {} Passkey(const Passkey&) {} Passkey& operator=(const Passkey&) = delete; }; class Access; class MyClass { …
-1
votes
2 answers

How to make an object to provide altering functionality for only certain users in C#?

I am creating an implementation of the half-edge data structure in C#. The details of this structure is not relevant for my question, so I will introduce it only as deep as required, but a brief summary is available on flipcode if someone…
mcserep
  • 3,231
  • 21
  • 36
-2
votes
1 answer

Vice Versa Of friendship(accessibility) in class is true or not In C++?

A friend class can access the members of the class containing the friend function. Is Its vice-versa i.e. the class can also access the members of it friend class is true?
Gaurav
  • 117
  • 9
-2
votes
1 answer

Even if "friend class rect" has been commented in square class why it is changing the private variable of rect class?

confused with below program for friend class use, please help me to solve that #include using namespace std; class square; class rect { public : rect(int w = 0, int h = 0) : width(w), height(h), volume(w*h) {} …
user2621476
  • 93
  • 1
  • 8
-2
votes
1 answer

no match for ‘operator>>’

I am trying to implement friend class. When I try to run code I get errors like . a3.cpp:85:5: error: `no match for ‘operator>>’` (operand types are ‘std::istream {aka std::basic_istream}’ and ‘int*’) cin>>this->telephone_number; …
user6108870
-2
votes
3 answers

friend function c++ inside class

i wrote this code but friend function is not working(foodmoney and hobbymoney are not declare in my friend function. where is my Error here ? #include using namespace std; class myBase { private: int friendvar; int foodmoney; …
1 2 3 4 5
6