friend

c++ templated friend class

Hello all, I'm trying to write an implementation of a 2-3-4 tree in c++. I'm it's been a while since I've used templates, and I'm getting some errors. Here's my extremely basic code framework: node.h: #ifndef TTFNODE_H #define TTFNODE_H template <class T> class TreeNode { private: Tre...

Interaction of namespace and friend in C++?

Is it possible to make a namespace friend of a class, say I have a unit test namespace with many classes and I wanted the test namespace to be friend to a class so that it has access to private implementation details. ...

Compiler error in declaring template friend class within a template class

Hello everybody. I have been trying to implement my own linked list class for didactic purposes. I specified the "List" class as friend inside the Iterator declaration, but it doesn't seem to compile. These are the interfaces of the 3 classes I've used: Node.h: #define null (Node<T> *) 0 template <class T> class Node { public: ...

How to create invite a friend in ruby on rails?

I want to create the ability for a User to go to a form and put a first name and email address and send an invitation via email. When the recipient clicks on the included link and registers, the Recipient and User are now "friends." Is there a good tutorial to get me started on this? ...

C++ special instance of template function for some type which is a template class itself

I got trouble in creating special instance of member template function of non-template class. I have, for example, class A with template member function F: class A {public: template <class T> int F (T arg) const; .... } and want to have a special instance of this template function F for type B: class B; ... template...

Friend mixin template?

Let's say I have two classes Foo and Bar, and I want to make Foo friends with Bar without changing Foo. Here's my attempt: class Foo { public: Foo(){} private: void privateFunction(){} }; template <class friendly, class newFriend> class friends : public friendly { private: friend newFriend; }; cla...

Overloading Output operator for a class template in a namespace.

I've this program #include <iostream> #include <sstream> #include <iterator> #include <vector> #include <algorithm> using namespace std ; #if 0 namespace skg { template <class T> struct Triplet ; } template <class T> ostream& operator<< (ostream& os, const skg::Triplet<T>& p_t) ; #endif namespace skg { template <class T> struc...

A C++ syntax question involving non trivial templating and friend declaration

Hi, The following code should be self explanatory. I have two questions regarding the used syntax (which is the syntax that must be used). I'll be forever grateful if you could provide me with answers for these presented questions. template <typename T> struct A { template <typename S> void f (const A<S> &s); template <typ...

How do I define friends in global namespace within another C++ namespace?

Hi, I'd like to define a binary operator on in the global namespace. The operator works on a class that is defined in another namespace and the operator should get access to the private members of that class. The problem I have is that I don't know how to scope that global operator when making it a friend in the class definition. I tri...

How do I define a friend class from the global namespace in another namespace?

In a previous Q&A (How do I define friends in global namespace within another C++ namespace?), the solution was given for making a friend function definition within a namespace that refers to a function in the global namespace. I have the same question for classes. class CBaseSD; namespace cb { class CBase { friend class ::CBaseSD...

Best Resources for Rails Social Networking Friendship

What do you all think are the best resources for adding a "friendship" system to your rails social networking sites? The main three I have found: Self-Referential Associations - Railscast acts_as_network has_many_friends However i find that the railscast one tends to be a bit simplistic, and a lack of implementation documentation for t...

Best UI/design patterns to find my users' friends who are also my users

What's a good design pattern to find my app's users' friends (facebook, linkedIn, twitter), etc who are also configured with my app? Eg, my party app has party organizers. The organizers add party people by name/email. Later a party person logs in via Facebook. I want to show her which of her friends will also be at the party. Should I...

C++: Why isn't operator placement new recognized as an inline friend function in a (template) class in VS2005?

I've inherited a Visual Studio 6.0 project to convert to 2005. It includes this fantastic MyClass class below that client code uses everywhere by invoking placement new on an instance of it (greatly simplified here): #include <new> #include <cstdio> template<class T> class MyClass { public: // This is what the author assumed would...

How to make google-test classes friends with my classes?

I heard there is a possibility to enable google-test TestCase classes friends to my classes, thus enabling tests to access my private/protected members. How to accomplish that? ...

PHP: friend classes and ungreedy caller function/class

Is there any way to get the caller function with something else than debug_backtrace()? I'm looking for a less greedy way to simulate scopes like friend or internal. Let's say I have a class A and a class B. Until now, I've been using debug_backtrace(), which is too greedy (IMHO). I thought of something like this: <?php class A...

Google App Engine - How to implement the activity stream in a social network

I want some ideas on the best practice to implement an activity stream for a social network im building in app engine (PYTHON) I first want to keep a log for all activities of each user - so that we have a history. i.e. someone became a friend, added a picture, changed their address etc. This way we have a users history available should...

Does it make a difference whether I put 'friend class xxxxx' in the public or private section?

class A1 { public: friend class B; } class A2 { private: friend class B; } Any difference? ...

Friend Assemblies in C#

I'm trying to create some 'friend assemblies' using the [InternalsVisibleTo()] attribute, but I can't seem to get it working. I've followed Microsoft's instructions for creating signed friend assemblies and I can't see where I'm going wrong. So I'll detail my steps here and hopefully someone can spot my deliberate mistake...? Create a s...

Friendness and derived class

Hi, Let's say I have the following class hierarchy: class Base { protected: virtual void foo() = 0; friend class Other; }; class Derived : public Base { protected: void foo() { /* Some implementation */ }; }; class Other { public: void bar() { Derived* a = new Derived(); a->foo(); // Compile...

friend declaration in C++

In Thinking in C++ by Bruce eckel, there is an example given regarding friend functions as // Declaration (incomplete type specification): struct X; struct Y { void f(X*); }; struct X { // Definition private: int i; public: friend void Y::f(X*); // Struct member friend }; void Y::f(X* x) { x->i = 47; } Now he explained this: N...