friend

Friends confusion

$11.4/5 - "[...]A friend function defined in a class is in the (lexical) scope of the class in which it is defined[...]" What does this statement mean? struct A{ typedef int MYINT; void f2(){f();} // Error, 'f' is undefined friend void f(){MYINT mi = 0;} // Why does this work, shouldn' it be A::MYINT? ...

c++. compile error. am trying to add friend template function with enum template parameter

Hello, dear programmers! Please help with the next code: typedef enum {a1, a2, a3} E; template<E e> int foo() { return static_cast<int>(e); } class A { A() {}; friend int foo<E e>(); }; The compiler says: error C2146: syntax erorr: missing "," before identifier "e" I would be glad if someone could explain my mistake. ...

operator overloading c++

Hey, I am trying to preform operator overloading in C++; for some reason the compiles keeps on giving me the error error: ‘bool Matrix::operator==(const Matrix&, const Matrix&)’ must take exactly one argument Now, I know that there is some way to to it with one argument using this, but I understood that by using friend I can do i...

.NET 'Private' Application

I create a .NET (WPF) Application, and compile it to .EXE. Then I create a second project, and add a reference to the compiled .exe, I can see all the classes and forms, and can use them for automation, etc. I want to prevent other people from using my compiled .exe as a .dll, so I changed all my classes to 'Friend' instead of 'Public',...

what is the difference between friend function and friend class?

what is the difference between friend function and friend class? and where should be use of friend keyword? ...

Class hierarchy in C#: how to do it correctly? ('friend' keyword wanted)

I have a class: public class MyClass { private List<string> folderList; // .... a lot of useful public methods here..... } Everything is fine. The list of folders is encapsulated, the class is accessible through public methods. OK. Now I need an "options" form that allows a user to choose folders for MyClass. There is a catc...

Is there a service, api or script out there to make a find/invite friends feature like in facebook?

I need to create a form where I can add a an account (gmail, msn, yahoo, twitter, facebook, etc) and it will automatically pull all of the contacts to invite them to the site. is there something out there already made? thanks. ...

Friend classes across different namespaces. Is that possible

Hello all, I'm having problems trying to use the friend feature of C++. I have these interfaces: #pragma once #include "Mesh3D.h" #include <string> namespace tools{ namespace sysInput{ class CGeometryManager3D { public: bool loadFromFile(render::CMesh3D& mesh, std::string filename); C...

.NET class access modifiers (friend and public)

I am developing a class library that will be used in several projects. In my class library, I have a "Shape" Class which has a number of properties. One of these properties is "Dimensions" returns a class with "Height" "Width" and "Depth" properties. How would I suppress the Dimension class from being viewable in the editor, whilst fre...

White-box testing - friends or preprocessor?

So, imagine we have a class like this class Testee { public: void Func() private: void auxFunc() }; and we want to do white-box unit-testing on it. Which do you think is a better approach? To declare the tester class a friend of the testee class? Or use the preprocessor like this: class Testee { public: void Fu...

Facebook php sdk Retrive friendlist problem

Title should say my words.Here is my basic code... <?php require_once 'fb-sdk/src/facebook.php'; // Create our Application instance. $facebook = new Facebook(array( 'appId' => 'xxxxxxx', 'secret' => 'xxxxxxxxxxxxxxxx', 'cookie' => true, )); $accessToken = $facebook->getAccessToken(); $session = $facebook->getSession(); $...

private inheritance, friends, and exception-handling

Hi. When class A privately inherits from class B it means that B is a private base class subobject of A. But not for friends, for friends it is a public sububject. And when there are multiple catch handlers the first one that matches (that is, if the exception type can be implicitly converted to the handler's parameter type) is called. S...

MSVC9.0 bug or misunderstanding of virtual inheritance and friends?

consider the following code: class A { friend class B; friend class C; }; class B: virtual private A { }; class C: private B { }; int main() { C x; //OK default constructor generated by compiler C y = x; //compiler error: copy-constructor unavailable in C y = x; //compiler error: assignment operator unavailable in...

Is a friend function defined in-class automatically inline?

If a member function is defined inside the class, it is an inline function. E.g. struct X { void mem_f() {} //mem_f is inline }; My question is whether a nonmember friend function defined inside the class is also automatically inline. E.g. struct Y { friend void friend_f() {} //is friend_f inline? }; A relevant quote/para...

C++ template friend operator overloading

What is wrong with my code? template<int E, int F> class Float { friend Float<E, F> operator+ (const Float<E, F> &lhs, const Float<E, F> &rhs); }; G++ just keeps warning: float.h:7: warning: friend declaration ‘Float<E, F> operator+(const Float<E, F>&, const Float<E, F>&)’ declares a non-template function float.h:7: warning: (if th...

PHP+Ajax : Add-a-friend system

I'm trying to make a little project for adding friends. When you click the add friend button you are sending an Ajax call with the friend id & username (they are the id and name attributes of each add button) to the add.php file. (The mysql structure is: 1 users table + X tables named the user's name(columns: friendid, ispending)) In the...

operator<< for nested class

I'm trying to overload the << operator for the nested class ArticleIterator. // ... class ArticleContainer { public: class ArticleIterator { // ... friend ostream& operator<<(ostream& out, const ArticleIterator& artit); }; // ... }; If I define operator<< like I usual...

friend declaration declares a non-template function

I have a base Class akin to the code below. I'm attempting to overload << to use with cout. However, g++ is saying: base.h:24: warning: friend declaration ‘std::ostream& operator<<(std::ostream&, Base<T>*)’ declares a non-template function base.h:24: warning: (if this is not what you intended, make sure the function template has alread...

Some compiler errors concerning an overloaded operator on a template in c++

Hi all, I have some code with a few errorr I do not understand how to fix at all. I have asked my professor and TA, and consulted the internet with no luck, apart from understanding more precisely what the errors mean. From what I can tell, the compiler is either confusing my overloaded operator with built in operators, or it is not re...