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

Using unnamed namespace to redefine friend class in an API and access private members?

I'm trying to access some private members of a class that's part of an API that I do not have the ability to change. Listing 1: api.h namespace api { class Bar; class Foo { public: const int& getSecret() const { return…
Dragos
  • 498
  • 4
  • 13
0
votes
2 answers

Non-friend operator+ with two parameters in Wandevoorde&Jossutis' book

Learning Expression templates. In Wandevoode and Jossutis's book Templates, the complete guide, section 18.2.3 The Operators, they define an operator+ with two arguments but not as a friend method. template
Kae
  • 279
  • 2
  • 10
0
votes
1 answer

why is @followed.email undefined?

I'm trying to create a friending system for my app. I am using active_relationships, passive_relationships, state_machine and the concept of followers,followed, following and followers. I have gotten myself in a bit of a knot comprehending how…
sss333
  • 105
  • 2
  • 13
0
votes
2 answers

friendship and operator overloading help

I have the following class #ifndef Container_H #define Container_H #include using namespace std; class Container{ friend bool operator==(const Container &rhs,const Container &lhs); public: void display(ostream & out) const; …
silent
  • 2,836
  • 10
  • 47
  • 73
0
votes
1 answer

Cannot access private member declared in class

I have to write a C++ code must also perform sorting of multiple objects of the following class: class student { int roll, m[5], total; bool pass; char name[30]; public: void read(); void result(); void print(); void…
Abhilash
  • 2,026
  • 17
  • 21
0
votes
1 answer

Using pointers to access friend class member functions

Here are two classes class A{ A(int val):Val(val){} int getVal(){return Val;} friend class B; private: int Val; } class B{ B(A* ptr):PTR(ptr){} private: A* PTR; } In the main function I create the objects…
0
votes
2 answers

C++ - friend functions

I am trying to make a simple friend function work, but not in just one source file. I seem to get an error and I can't seem to find an answer why. Please have a look at my code: ----------classOne.h-------------- #ifndef CLASSONE_H_ #define…
tenkii
  • 449
  • 2
  • 10
  • 23
0
votes
2 answers

Adding a Two Way Friend Relation on Parse for Android

I am currently working on an app with a friendship feature similar to Facebook(a request is sent and if accepted they both become friends). The sending user can select multiple users from a list and send them all invites at once. When this happens,…
Rich Luick
  • 2,354
  • 22
  • 35
0
votes
1 answer

iOS Facebook how to get suggested friends like Hangtime or DrinkAdvisor

I saw in Hangtime app or DrinkAdvisor app, when I used Facebook to register & login, and in Friends tab, I can see list of Suggested Friends, I guess this list include people that I interract often, ie: like their photos, chat with them ... I'm not…
kenvu
  • 343
  • 6
  • 18
0
votes
0 answers

how can we make a virtual function a friend of another class?

I have the below program where Derived class is inherited from Base class. class Base { int p_var; public: virtual void function() { cout << "Function() of class Base"<
arjun jawalkar
  • 138
  • 1
  • 10
0
votes
2 answers

C++ Useless Friend Function Declaration

Well, I declared a friend function which is in: // user-proc.h class cregister{ private: levy user; // typedef struct int testp; public: friend void test(); cregister(levy &tmp); levy getUser(); void displayUser(levy &); }; Then I…
0
votes
1 answer

Friend template function specification

I have a class in which friendship with templated operator >> is established: class MyInputStream { ... private: std::istream& impl; template friend MyInputStream& operator>> (MyInputStream& stream, T& outParam); } now I define…
Alex B.
  • 348
  • 2
  • 12
0
votes
2 answers

error message if nothing to show from db

how show message if nothing to show from db message name "you dont have any friend" here is php code $mid = mysql_real_escape_string($_COOKIE['member_id']); $res = mysql_query(" SELECT profile_friends.friends_friend_id, members.name,…
0
votes
1 answer

Undefined reference to friend operator

In my code I have 2 classes declared in header "Geometry.h", Vector & Point. Inside Point class, I have following: class Point { // other stuff friend Vector operator-(const Point& lhs, const Point& rhs); } Vector is defined in "Vector.cpp" &…
Alexander Bily
  • 925
  • 5
  • 18
0
votes
2 answers

C++ static list with private constructor

I apologize if this has been asked, I'm not sure how one best words it and couldn't really find it. I essentially have a class that I want to maintain a map of itself, and that list should have the only instantiations of the object. using…
bathtub
  • 426
  • 3
  • 15