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
2 answers

specialize friend operator in template class previously defined error

I tried to specialize << operator for char in my template class hpp template class tablicowy{ public: T * tablica; int rozmiar; public: tablicowy(T arr[], int n){ { tablica = arr; rozmiar = n; …
0
votes
1 answer

Provide a proper operator<< with variadic template specialization

When providing the operator<< for a specialization of a template class, clang likes the inline friend form: #include template struct Hello; template struct Hello { template
DarioP
  • 5,377
  • 1
  • 33
  • 52
0
votes
1 answer

What are the criteria for making a function a member vs. a friend?

When I can decide whether a particular function/operator should be declared as a friend function/operator for a class or a member function/operator of a class.?
0
votes
0 answers

Is it possible to declare a template class as a friend class without specifying the template parameters

Here is a small code example : template class A { // } class B { friend class A<..> } In this case, I want A to be declared as a friend class but without specifying the template parameters...
SagiLow
  • 5,721
  • 9
  • 60
  • 115
0
votes
3 answers

Pointer to base class-argument type in friend function

I'm writing a C++ program involving polymorphism. I need to overload the operators "<<" and ">>" as friend functions. I have the base class base and 3 derived classes: der1,der2,der3 and a pointer to the base class * p. If I declare the functions…
flaviumanica
  • 195
  • 1
  • 4
  • 14
0
votes
3 answers

Graph DB, create node for friend request?

Short and simple question: For a social network platform would you create a separate node for the friend requests and creating the edge after confirmation, or creating the edge directly and set a confirmed flag? What are the advantages /…
Vincenzo
  • 1,158
  • 11
  • 18
0
votes
1 answer

facebook: is possible to use send message for predefined users?

I need to send to user's friends in facebook some link from my site or predefined message. I got the list friends by this: FB.api( "/me/taggable_friends", function (response) { if (response &&…
Eugene Shmorgun
  • 2,083
  • 12
  • 42
  • 67
0
votes
3 answers

C++ Friend Function Does Not Have Access To Private Member

Friend function unable to access private member of the class in which it was declared I am trying to recreate a sample program I am reading in a book demonstrating the use of a friend function. I am getting an error in the ever annoying…
Dominic Farolino
  • 1,362
  • 1
  • 20
  • 40
0
votes
1 answer

Provide friendship to static template function (non-member)?

This is similar to How to allow template function to have friend(-like) access?, but I'm working with a static template function (non-member). I'm trying to accomplish the following. Integer.h: class Integer { ... // Forward declare due…
jww
  • 97,681
  • 90
  • 411
  • 885
0
votes
0 answers

friend function, istream overloading>>, if space is entered the next input skips

I am using friend function with istream and trying to take multiple inputs. But if i enter a space in the first input, it misses the second input(second input becomes whatever is entered after the space) and moves to asking for third input. Why is…
Sarmad Asif
  • 89
  • 1
  • 10
0
votes
0 answers

C++ Accessing a class' private member from another friend class' function

I am trying to create a basic airport system. I have some classes which are named in info, and all of those classes are very similar to the Airport class. class Airport{ private: friend class SystemManager; friend…
karakanb
  • 37
  • 5
0
votes
3 answers

Friend function won't get private variables from class

I have a homework assignment that asks for me to make a class named Coord containing two double variables named xval and yval. In the class, there should be construtor and display methods and a friend function named conPol(). convPol() should accept…
TPA
  • 7
  • 2
0
votes
1 answer

assert as a friend class

I can not declare neither assert class, nor assert function as a friendly to my class. Am I right with such a declaration? class Baka { private: friend assert; //invalid friend declaration friend void assert(); //expected an…
Entrack
  • 51
  • 1
  • 1
  • 10
0
votes
1 answer

send a friend in modal bootstrap

Well, before asking here I have tried to find an answer for the issue I work with. Maybe someone who knows will help to find solution. I'm using bootstrap framework and here I have a "send friend" button which shows a modal fill-in form. here's…
Bogdan
  • 85
  • 1
  • 3
  • 9
0
votes
3 answers

c++ friend class as argument for ctor

I am wondering how come this code correct and how the compiler knows to first create an obj of class A, I would think it shouldn't compile since B's ctor request an argument of type A not int class A { int a1; public: A(int i) { cout <<…
Hillel
  • 301
  • 1
  • 11