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
1 answer

friend function + operator overloading

I am working on a project for class that is a sort of payroll. Part of the prompt says "You may define a friend function that overloads << for displaying the Employee object information(i.e. the overloading << function will call the virtual print…
Lunch
  • 57
  • 1
  • 1
  • 7
0
votes
2 answers

Accessibility of C++ vector in derived class from base class

My scenario is simplified in the following example: #include #include using namespace std; class C; class A { protected: C * cPointer; A(); virtual void updateList() = 0; void callFunc(); }; class B : public…
Code Warrior
  • 133
  • 1
  • 3
  • 15
0
votes
1 answer

Getting an id value

I'm currently working on a friendshipsystem. To accept a friend I need to get the friendship_id value. Based on the email (from the session) I can get a lot of information, such as surname, name, photo, ID NUMBER,... from the specific…
Marnix Verhulst
  • 161
  • 1
  • 2
  • 9
0
votes
1 answer

c++ forward declaration for a friend function in imbricated classes

I am trying to define a function member of a class Extraction FRIEND with a class Descripteur, but when I compile I get the following error : *Descripteurs.h:24:57: error: invalid use of incomplete type ‘class Extraction’ friend void…
alexis
  • 129
  • 2
  • 2
  • 12
0
votes
1 answer

private destructor friend function

Friend function destructs pointer, still I am able to access functions of the class with the pointer. #include using namespace std; // A class with private destuctor class Test { private: ~Test() { cout<<"Inside…
0
votes
1 answer

friend member of a class operating on private members c++

I am learning about friends in classes and my problem is: I want funcC3() to set and permanently change C1::a value, how to do it? I want global function gfunc() to be able to do the same, how? Could you please provide me the way i do it, because…
beginh
  • 1,133
  • 3
  • 26
  • 36
0
votes
1 answer

friend member function in C++ - forward declaration not working

I'm having a situation similar to the one described in Specify a class member function as a friend of another class?. However in my case, class B needs to know class A since it's using it, so the solution given in that thread is not working for me.…
0
votes
1 answer

Managin friends in mysql database for social networking site

I have long been searching for an answer to this watched a few videos but I can't seem to find an good answer. I want to make a friend system on my site. I have currently set up a many to many system I think is right. Am I supposed to have one…
0
votes
1 answer

How to use a common Friend Function in c++?

When i execute the code below it generates 2 errors c1::x is not accessible and missing ) in line9. Please explain. Thanks in advance... #include class c1{ int x; public: void input(){ cout<<"Enter length : "; …
rippy
  • 195
  • 3
  • 5
  • 14
0
votes
1 answer

Circular dependency of class delclarations

I have two classes with separate headers: class Renderer and class Texture. The Texture instance is designed to manage some data that resides in the memory pool of a Renderer, and thus a Texture instance cannot exist independently of a Renderer…
jms
  • 719
  • 2
  • 8
  • 18
0
votes
1 answer

Error in "The C++ Programming Language" Section "23.4.7 Friends"

I have been trying to get the following code work from the book "The C++ Programming Language (4th Edition)" section "23.4.7 Friends" but could not succeed. template class Matrix; template class Vector { T v[4]; public: …
Benji Mizrahi
  • 2,154
  • 2
  • 23
  • 38
0
votes
1 answer

Using Unity Facebook SDK 5.0.3, how can I get N random friends?

What would the FB.API call be to get 10 random friends? I am pretty sure this can be done with an fql query, but I do not know the exact syntax. It would have the form: FB.API(fqlQuery, Facebook.HttpMethod.GET, getNRandomFriendsCallback); So my…
0
votes
1 answer

Query for max to_date for one user id?

I am getting some unexpected results from a SQL query. Table data: users: id username 1 admin 2 x1 3 y1 4 z1 my_connections: id user_id friend_user_id status 1 1 2 201 2 2 1 201 3 2 4 …
0
votes
2 answers

C++ How to avoid friend template functions with home-made intrusive lists

I need an intrusive, sorted, double-linked list. I do not want to use boost::intrusive, so I'm doing this myself and running into an issue For a doubly-linked list there are several operations, here is just one of them which will help to illustrate…
Badmanchild
  • 990
  • 9
  • 18
0
votes
1 answer

c++ friend function implemented in a class can't access privates

I'm trying to define 2 classes, declare a friend function in one of them and implement it in the other. I am actually trying to get exactly what found in this post working: How can friend function be declared for only one particular function and…
theexplorer
  • 359
  • 1
  • 5
  • 21