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

Overload stream insertion and extraction operator

I'm trying to overload both the stream insertion and extraction operator for my Entrepreneur class. I've got the following in my Entrepreneur class: friend istream& Entrepreneur::operator>> (istream &input, Entrepreneur &entrepreneur) { cout <<…
user2917054
0
votes
1 answer

Why can't I make this member function friend of another class?

#ifndef BUTTONS_H #define BUTTONS_H class Window; class Buttons { friend int main(); friend void Window::setCloseButtonCaption(string); public: Buttons(); Buttons(string, Window&); ~Buttons(); void setCaption(string); …
Firdaws
  • 93
  • 1
  • 10
0
votes
1 answer

Does Upcasting in C++ Allow Access to Parent's Private Members or Friends

From what I have learned in class, derived classes do not inherit their parent class's: Constructors/Destructors Friends Private Members However if we upcasted the derived class to its parent class, would we have access to the private members of…
aj1996
  • 15
  • 6
0
votes
1 answer

C++ library making, hiding destructor/constructor without friend in header

I have to make a shared library and now I'm facing with the following problem. (MSVC2015). I want to hide constructor/destructor like in class A, and I have a "factory" class like B. class A { public: private: A() {}; …
bjoska
  • 3
  • 1
0
votes
1 answer

Google Friend Connect fcauth cookie in php

this may be easy for most of you .. but not me. I am using some "sample" Google code - as it fits my purpose so why change what works - but for the life of me I cannot access/find/get etc the FCAuth cookie after a user is logged in. Help please -…
user351657
  • 353
  • 2
  • 8
  • 17
0
votes
3 answers

Trouble with friends: How to grant private access to an inner class?

Here I have a simplified version of a linked-list implementation I have been working on. I would like to keep a count of component elements (nodes) as a private member, and then let the Component constructor and destructor completely handle the…
Aposhian
  • 801
  • 1
  • 10
  • 27
0
votes
0 answers

Add Friend not changing to Request Sent after clicking Add Friend

Am using following code to send request to user (BELLOW IS JUST A PART OF FILE) //addFriend functionality if (isset($_SESSION['username']) && $_SESSION['username'] != "") { $isFriend = false; …
sanoj lawrence
  • 951
  • 5
  • 29
  • 69
0
votes
1 answer

Is it possible to make a generic function with multiple parameters a friend in a class in c++?

I'm want to make the function operator+ a friend of class Matrix. I could use the function as is but I want to know if this is possible. I've tried several ways but all resulted in linker errors and the program didn't compile. I'm currently…
Denis Nutiu
  • 1,178
  • 15
  • 22
0
votes
1 answer

MSVC compiler bug causing error with iterators and friend functions?

I've been working on a small-scale test to see if I can figure out some compiler-specific larger-scale problems with a larger container. The following code works fine in GCC but causes the following error code in Visual Studio 2010 and 2013: "Error …
metamorphosis
  • 1,972
  • 16
  • 25
0
votes
0 answers

How to declare friend function of non-member function declared in a class by friend keyword

I have two questions about friend declaration in the following code. (1) I declared a friend function. The program looks working but I got a warning from compiler. The original function is a non-member function defined in a class by friend…
mora
  • 2,217
  • 4
  • 22
  • 32
0
votes
2 answers

Template classes and the friend keyword in c++ (specific example refers to boost::multi_index)

so you have a class employee class employee { public: employee(const string &name, int id) : m_name(name) , m_id(id) {} const string &getName() const { return m_name; } int getID() const { return m_id; } private: string &m_name; …
shaz
  • 2,317
  • 4
  • 27
  • 37
0
votes
1 answer

Facebook FQL how to know uid1 and uid2 are friend

I tried this query SELECT uid1,uid2 from friend where uid1= 437574483052913 AND uid2 = 314664215408124 I got an empty return . When I search their name in their friends list , I see they are friend. Facebook depredated all the find friend…
0
votes
3 answers

How can I call function of another class?

class Bishop : public ChessPiece { public: friend class Queen; Bishop(string colorIn, string nameIn); //isLegalMove for bishop //implemented this function for queen bool isLegalBishopMove(int xSrc, int ySrc, int xDest, int…
0
votes
3 answers

Declaration of Linked List please?

I am trying to implement a LinkedList for the first time. I almost finished declaring the header file, but I'm getting this one minor error that won't go away. Where I declare the class LinkedList and Iterator below the Node class, I keep getting…
Vivek Reddy
  • 92
  • 1
  • 1
  • 9
0
votes
1 answer

Friend ostream operator << wont acces private fields

It just wont acces private fields .hpp: private: std::string model; public: Piekarnik &operator << (const Ciasto &ciasto); friend std::ostream &operator<<(std::ostream &os, const Ciasto &ciasto); .cpp: Piekarnik…
foxale
  • 127
  • 9