Questions tagged [friend]

In object-oriented programming, friend refers to a method or class that has access to some non-public aspects of a particular class.

In object-oriented programming, friend refers to a method or class that has access to some non-public aspects of a particular class.

Different programming languages use the friend keyword differently. Make sure it is clear which language you are asking about.

1518 questions
0
votes
0 answers

Can a template class has a templated friend declaration?

In other words does this code work? #include template class ImFriendWith { int privValue; public: ImFriendWith(int v): privValue{v} {}; friend class T; // <-- THIS }; struct Befriended { …
Felix.leg
  • 622
  • 1
  • 4
  • 13
0
votes
1 answer

Trying to skips steps in a riddle my friend made with morse code by brute force in python

I used the following code from a another's question to brute force the morse code with all letters, but didn't seem to make any words that would make sense. How can I add numbers and punctuation to this code? I'm not a coder, so help would be…
0
votes
0 answers

comparing objects of class in a vector using operator overloading

so I have a class A - parent and B - child, i also have a class c thats unrelated that holds a vector of child objects. Im trying to sort the vector using a compare function in class A that uses operator overloading and having diffcultly making this…
Colton F
  • 1
  • 1
0
votes
2 answers

Template friend error, error: template argument required for 'class LinkedList'

Hi I am tryna friend a class linkedlist in iterator but idk how to do it with templates class Iterator{ private: node* v; public: Iterator(node* u){ v = u; } T& operator*(){ …
0
votes
1 answer

Friend function for class in dll

Lets say I have the following class in my dll class Test { private: int x; }; and following function in client side application which uses my dll void test(); Is there a way to make test function friend for Test class?
ArthurBesse
  • 325
  • 1
  • 12
0
votes
1 answer

C++ compiler doesn't consider friend class declaration

I'm trying to rewrite the program shown in the textbook (C++ Primer). This is small email-like program that contains two main Message and Folder classes. Source files are as below: Folder.h #pragma once #include #include #include…
Elgin Cahangirov
  • 1,932
  • 4
  • 24
  • 45
0
votes
2 answers

overloaded extraction operator won't friend in C++

I'm working on extraction and insertion overloads. And I can't access the private variables while using friend. This is my code based a standard tutorials and what my teacher gave me to work with Main.cpp #include #include "Obj.h" using…
ron252
  • 21
  • 8
0
votes
1 answer

problem with accesing protected methods in friend class

I'm starting a new project and I have trouble with accessing protected methods of Organism inside World class. I suppose there must be some error with my definition of World being a friend of organism. I tried calling some method from Organism…
Michał Turek
  • 701
  • 3
  • 21
0
votes
1 answer

Call to deleted constructor of std::__1::ostream error on operator<< overload

I am trying to get a function to be recognized as a friend but I can not figure out what I am doing wrong. I tried changing things to references and moving things in and out of the namespace and header cpp. There is nothing that I notice as the…
ron252
  • 21
  • 8
0
votes
1 answer

User Control (Windows Form) make elements 'Shared'

Problem: I am building a Custom Task Pane in Outlook (VS 2019) using VB. Coming along but I am not able to find how to keep the controls added (textbox, Listbox, ect.) to be shared and accessible from other User Controls, modules, etc. Current Fix:…
0
votes
1 answer

error:expected";" at end of member declaration and expected unqualified id before token "<"

I am trying to write a vector class which includes a friend function sort(algorithm is bubble sort) and I have some difficulty in this function. This sort function is also a template function of template iterator and iterator is typedef of T* in…
dubugger
  • 89
  • 6
0
votes
1 answer

Befriending a function template defined in another file in C++11?

I have written a custom vector class template and print_vector function template that is supposed to print the content of my custom vector class. The print_vector function uses v.sz and v.elem which are declared private inside the vector class.…
Enigma
  • 53
  • 9
0
votes
1 answer

Forward declaration of two dependend classes with friend function

I have two classes. One depends on the other class and the other one contains a function that is friend to the first class. There's a lot of other stuff in this classes but this is what it boils down to: class LightBase; class Color { friend…
glades
  • 3,778
  • 1
  • 12
  • 34
0
votes
1 answer

How to save the friend ID in Facebook TD Friend Selector

I used this Facebook Friend Selector script from GitHub: http://playground.thesedays.com/tdfriendselector/ and it works perfectly fine. But I don't know how to save the selected output friend in PHP as the README file documentation is very poor.…
0
votes
1 answer

Template Friend for Superclass

I have a non-templatized class (Par_list_elem), and I would like to give access to its internals to the class Par_list (to build an intrusive list). The catch: I need Par_list_elem and all of its subclasses to be accessible to Par_list. In detail,…
bcr
  • 1,328
  • 11
  • 27