friend

Set a project default for VB.NET projects so that the default Modifiers property for controls is Private

早过忘川 提交于 2019-12-10 13:19:11
问题 Is it possible to set a project default for VB.NET winforms projects so that the default Modifier for controls added to winforms is Private (not Friend)? I know there's a "modifiers" property in the properties window so I can set it for each individual control... however I would like to change the project so from now on myself and other developers have to specifically decide to change from private . (Which I would strongly discourage them from doing). I believe there is no way of doing this,

Restrict the scope of class instances accessible by multiple template parameter friend function

╄→尐↘猪︶ㄣ 提交于 2019-12-10 13:15:55
问题 I would like to know if what I am aiming for is possible. I have a class Class such that #include<iostream> template<class T> class Class; template<class T, class W> Class<W> f(Class<T>& C, const Class<T>& D); template<class T> class Class { protected: // this could be private T m_t; public: Class(): m_t(T()) {} Class(T t): m_t(t) {} T& getT() { return m_t; } template<class U, class W> friend Class<W> f(Class<U>& C, const Class<U>& D); }; template<class T, class W> Class<W> f(Class<T>& C,

Issue with friend template functions clang++ / msvc++ and enable_if

这一生的挚爱 提交于 2019-12-10 10:42:09
问题 I get a compiler error in clang++. MSVC++ is happy. I believe my declarations are correct. Am I incorrect in my beliefs and I am "lucky" in MSVC? Is there a non #ifndef _MSC_VER ... public: way to make this work in both compilers? I'd like to keep the constructor private. The real code is slightly more complex. (additional template meta-programming and "perfect forwarding") The following is a distilled version for the question and to isolate the issue as much as possible. I've tried a number

why does g++ need both definitions of template class and its friend function?

孤人 提交于 2019-12-10 10:34:01
问题 I want to write a friend function for a template class. In visual studio, I can ignore the pre-definition both. But in g++, it is mandatory. Why? #include <iostream> using namespace std; // g++ needs, vs do not needs template <class T> class A; template <class T> ostream & operator<<(ostream & c, const A<T> & v); //- end of g++ needs template <class T> class A { T _v; public: A() {} A(T v) : _v(v) {} friend ostream & operator<<<T>(ostream & c, const A<T> & v); }; template <class T> ostream &

Friend access to protected nested class

笑着哭i 提交于 2019-12-09 02:54:20
问题 I have the following C++ code: class A { protected: struct Nested { int x; }; }; class B: public A { friend class C; }; class C { void m1() { B::Nested n; // or A::Nested } }; Compiling this snippet with g++ 4.4, it does not make a difference whether I use B::Nested or A::Nested in m1. Clang accepts B::Nested , but does not compile if I A::Nested . Is that a bug in g++ or in clang? 回答1: According to the Standard, GCC is correct and Clang is wrong. It says at 11.2/4 A member m is accessible

Does a friend see base classes?

◇◆丶佛笑我妖孽 提交于 2019-12-08 20:27:22
问题 Given the sample code: class Base { public: bool pub; protected: bool prot; }; class Derived : private Base { friend class MyFriend; }; class MyFriend { Derived _derived; void test() { // Does standard provide me access to _derived.pub and _derived.prot? cout << "Am I allowed access to this: " << _derived.pub << " and this: " << _derived.prot; } }; Does being a friend give me all access I would get as if I was a member function within the class to which I am a friend? In other words, can I

Unit test a class declared friend (internal)

僤鯓⒐⒋嵵緔 提交于 2019-12-08 17:40:07
问题 In some of my test helper code, I have a IDbSet(Of T) implementation called FakeDbSet(Of T) that mocks a lot of EF behavior without an actual database. I have the class declared Friend because I want to force all code to interact with it like an IDbSet(Of T) . Internally (ie within my Testing assembly), I access a lot of the public members of the class which I want to be able to test. The problem is, I keep my unit tests in a separate assembly Test.Unit which means they cannot access my

Is it possible to invoke an injected friend template function?

℡╲_俬逩灬. 提交于 2019-12-08 09:33:38
问题 To be consistent with other (non-template) functions in a class I wanted to define and invoke a friend template function. I can define it with no problem (see function t below). namespace ns{ struct S{ void m() const{} friend void f(S const&){} template<class T> friend void t(S const&){} }; template<class T> void t2(S const& s){} } However later I am not able to invoke this t function in any way? int main(){ ns::S s; s.m(); f(s); // t<int>(s); // error: ‘t’ was not declared in this scope (I

“Request Dialog” requestCallback when clicking Cancel or Close button

我只是一个虾纸丫 提交于 2019-12-08 06:45:17
问题 I am new into Facebook application development and also newbie about JavaScript and PHP programming. I currently developing a Facebook application but currently stuck with Request Dialog window. When the Request Dialog appears, I choose friends I want and then click "Send Requests", the requestCallback(response) are executed and friends who getting requests are notified as expected. But, If I click "Cancel" or the blue-colored close button, the requestCallback(response) is also executed but

How to make template function friend of template class

限于喜欢 提交于 2019-12-08 05:26:50
问题 I have a template class with private constructor and destructor: template <typename T> class Client { private: Client(...) {} ~Client() {} template <typename U> friend class Client<T>& initialize(...); }; template <typename T> Client<T> initialize(...) { Client<T> client = new Client<T>(...); } I'm not sure of the correct syntax for the friend. Can anybody help? 回答1: Ignoring the ellipses (which I assume mean "a bunch of parameters that aren't relevant to the question"), this should work: