friend-class Questions
6
Solved
Given class A, which contains sets of raw data, and class B, which contains a re-organized version (GUI ready) of that data I would like to make the raw data in A visible in B.
Clearly the raw dat...
Casar asked 1/2, 2010 at 16:36
1
Solved
Following the Czech song from Eurovision 2019 in Tel-Aviv
It is known that in C++ a friend of a friend is not (automatically) a friend.
Clang however differs on the following code with GCC and MSVC...
Swashbuckling asked 28/5, 2021 at 15:26
2
Solved
Consider this code:
template <typename T>
class Singleton
{
};
class Logger : public Singleton<Logger> {
friend class Singleton;
};
It compiles in gcc and clang, but is it valid? [te...
Affirmative asked 25/1, 2021 at 16:42
1
Solved
Is it possible to make friend of a class, all possible variants of a class-template?
Just to clarify, for example, something like this:
class A
{ friend template B; } // syntactic error yeah
So an...
Kelcy asked 5/8, 2020 at 1:1
7
Solved
What is the equivalent of a 'friend' keyword in C Sharp?
How do I use the 'internal' keyword?
I have read that 'internal' keyword is a replacement for 'friend' in C#.
I am using a DLL in my C# p...
Octillion asked 15/1, 2009 at 2:58
4
Solved
here im not understanding the concept very well or i am right.... So lets take this "friend" class example here:
class MyClass{
friend class AnotherClass;
private:
int secret;
}
class AnotherCla...
Pokorny asked 22/4, 2016 at 10:25
2
Solved
We can access private variables of another class when we define copy or move constructors. Does C++ make them friend to each other automatically?
For example:
my_str::my_str(my_str&& m) ...
Garibull asked 25/11, 2019 at 6:56
4
Solved
I have two classes; Salary that is intended to hold information and calculations regarding the salary of an employee and Employee that has an object of type class Salary and some members like name ...
Clement asked 23/4, 2019 at 21:56
2
In C++ there is something called a friend class. As far as I know, there's no such thing in TypeScript/JavaScript. Is there a way to simulate such behavior of friend class in TypeScript/JavaScript?...
Prefix asked 23/8, 2017 at 18:53
2
I was wondering if there is a way such that we make all functions defined within a specific namespace friend with a class?
In particular, I have a class, for example:
class C {
private:
// ...
...
Fazio asked 30/12, 2013 at 11:7
1
Solved
Suppose I have a template class that I am trying to declare as a friend class. Should I forward declare the class or give it its own template?
Example:
template <typename E>
class SLinkedLi...
Arched asked 18/9, 2015 at 23:5
8
Solved
I was wondering why Java has been designed without the frienddirective that is available in C++ to allow finer control over which methods and instance variables are available from outside the packa...
Nautch asked 10/1, 2011 at 14:5
2
Solved
is it possible to somehow make a partial template specification a friend class? I.e. consider you have the following template class
template <class T> class X{
T t;
};
Now you have partia...
Temperance asked 14/6, 2012 at 21:0
4
Solved
I've just recently learned about friend class concept in C++ (I've googled around for a bit, but this answer made me laugh until I remembered the most important parts), and I'm trying to incorporat...
Frore asked 27/3, 2012 at 13:43
2
Solved
I have a Factory class that creates a Widget object. The Factory object needs to callback a "private method" of the Widget object at a later time to pass it some ajax info. So far, the only impleme...
Arena asked 21/6, 2011 at 10:36
1
In Thinking in C++ Volume 1, chapter 16: Introduction to Templates.
The context:
Notice that instead of just saying:
friend iterator; // Make it a friend
This code has:
friend class ...
Sussna asked 1/6, 2011 at 3:27
4
Is there any way around this:
class B;
class C {
public:
C() { }
private:
int i;
friend B::B();
};
class B {
public:
B() { }
private:
int i;
friend C::C();
};
Gives error:
prog.cp...
Falter asked 28/5, 2011 at 0:3
4
When defining a class as a friend class, does it matter in which accessor section the definitions is placed, and if so does that change the members the friend has access to?
class aclass
{
private...
Collegian asked 7/4, 2011 at 3:26
6
Solved
Is it better to add functions that return the internal state of an object for unit testing, as opposed to making the testing class a friend? - especially, when there is no use for the functions exc...
Yeeyegg asked 19/7, 2009 at 4:35
3
Solved
In a project I'm working on, I have a Score class, defined below in score.h. I am trying to overload it so, when a << operation is performed on it, _points + " " + _name is printed.
Here's ...
Chema asked 13/5, 2010 at 15:59
3
Solved
Since class friendship is not inherited in C++, what's the best way to "fake" it?
I was thinking about exposing the friend class's private interface through protected methods in the to-be-inherite...
Harlequin asked 5/11, 2009 at 15:36
1
© 2022 - 2024 — McMap. All rights reserved.