private

error saying class defined as public is private

六月ゝ 毕业季﹏ 提交于 2019-12-11 08:29:38
问题 Making a 3D Tic Tac Toe game using class inheritance. Compiler error as follows. line: 43 [Error] 'void CPUClass::cpu()' is private 190 [Error] within this context Looking at my code, I've clearly defined cpu() as public. Any ideas what I'm overlooking? #include <iostream> #include <time.h> //seeding random #include <windows.h> using namespace std; class TTT { public: void setup(); void display(); void cpu(); void player(); void check(int); protected: int cp; //comp points int pp; //player

Using Prototype's Class.create to define private/protected properties and methods

孤街浪徒 提交于 2019-12-11 07:48:45
问题 There is a good generalized method for defining private and protected properties and methods in Javascript, here on the site. However, the current version of Prototype (1.6.0) doesn't have a built-in way to define them through its Class.create() syntax. I'm curious what the best practices are when developers want to define private and protected properties and methods when using Prototype. Is there a better way than the generic one? 回答1: What you can do is using local variables in your

ResourceManager override GetResourceFileName

喜你入骨 提交于 2019-12-11 06:57:14
问题 I want to override a method in the System.Resources.ResourceManager class in mscorlib v4. I want to override the method GetResourceFileName like this; protected override string GetResourceFileName(CultureInfo culture) { string resourceFileName = base.GetResourceFileName(culture); return resourceFileName.Replace(".resources", ".resx"); } The problem is, to instanciate a ResourceManager class I must use the static method CreateFileBasedResourceManager, which returns a new instance of the

While unit testing I frequently require to test internal (private) logic, what is the best practice for this?

霸气de小男生 提交于 2019-12-11 05:33:05
问题 I believe everyone encounters a case when there's necessity to test internal wiring of the class/object. I know that in compiled languages this could be done through conditional compiling. Is this what I should do for JavaScript as well? What's the usual way to accomplish such task? Maybe I should just treat the class/object as a Black Box and only test it's outcomes? 回答1: Testing object's public contract (ie. black box testing you mentioned) most of the times should be enough. Proper test

Does “friending” the base class in CRTP inheritance affect the child class as well?

僤鯓⒐⒋嵵緔 提交于 2019-12-11 04:49:47
问题 In an attempt to answer another question, I came up with a scheme to force children of a CRTP base class to accept a particular type as a parameter in their constructors: make the parameter type's constructor private , assign the CRTP base class as a friend , and declare the parameter type as a parameter for the base class constructor as well. However, when I tried to demonstrate that this scheme provided the desired protections via access violations, I found that even though the parameter

True privateness in Python

梦想的初衷 提交于 2019-12-11 03:59:50
问题 PEP 8 states that (emphasis mine): We don't use the term "private" here, since no attribute is really private in Python ( without a generally unnecessary amount of work ). I guess it refers to defining the actual class in some other language and then exposing only the public members to the interpreter. Is there some other way to achieve true privateness in Python? I'm asking just out of curiosity. 回答1: No, nothing is truly private in Python. If you know the method name, you can get it. I

Does importing of packages change visibility of classes?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-10 20:33:20
问题 I jsut learned that A class may be declared with the modifier public, in which case that class is visible to all classes everywhere. If a class has no modifier (the default, also known as package-private), it is visible only within its own package. This is a clear statement. But this information interfere with my understanding of importing of packages (which easily can be wrong). I thought that importing a package I make classes from the imported package visible to the importing class. So,

Is there a way to have private functions in public traits?

纵然是瞬间 提交于 2019-12-10 15:13:57
问题 I have an implementation for a public trait that repeats some work over multiple functions, so I'd like to DRY it up with a function that does the shared work, to be called from the functions actually meant to be used. So I have: fn do_private_thing() fn do_pub_1() fn do_pub_2() I don't want do_private_thing() to be exposed in docs or used directly, because it doesn't do anything useful from the perspective of a user of the trait/implementation. But functions in public traits are not private.

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,

delegating into private parts

为君一笑 提交于 2019-12-10 12:34:33
问题 Sometimes, C++'s notion of privacy just baffles me :-) class Foo { struct Bar; Bar* p; public: Bar* operator->() const { return p; } }; struct Foo::Bar { void baz() { std::cout << "inside baz\n"; } }; int main() { Foo::Bar b; // error: 'struct Foo::Bar' is private within this context Foo f; f->baz(); // fine } Since Foo::Bar is private , I cannot declare b in main . Yet I can call methods from Foo::Bar just fine. Why the hell is this allowed? Was that an accident or by design? Oh wait, it