class

Java - Method accessibility inside package-private class?

自古美人都是妖i 提交于 2019-12-30 08:12:53
问题 If I have a java class which is package-private (declared with "class", not "public class"), there is really no difference if the methods inside are declared public or protected or package-private, right? So which should I use, or when should I use which? I'm a bit confused. 回答1: If I have a java class which is package-private (declared with "class", not "public class"), there is really no difference if the methods inside are declared public or protected or package-private, right? Well maybe

Example of Class with User Input [closed]

陌路散爱 提交于 2019-12-30 07:48:20
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 4 years ago . In most of the examples I have seen online while (trying to) learn classes, the instances of the classes are defined by the programmer. Are there any ways of creating an instance of a class where it the variable that stores the class is defined by the user? This is an example of an object from

'[Class name]' does not name a type in C++

99封情书 提交于 2019-12-30 07:24:09
问题 I am programming a graph using a list of lists. For that, I have two classes, and each one of this classes has a pointer to another object of the same class and a pointer to the object of the second class. Here is the code: File V.h: #ifndef VERTICEPUNT_H #define VERTICEPUNT_H #include "A.cpp" typedef char E; class V { public: E etiqueta; V* siguiente; A* primera; //<- Error: 'A' does not name a type V(); ~V(); }; #endif // VERTICEPUNT_H File V.cpp: #include "V.h" V::V() { etiqueta = ' ';

How to insert another table row between two table rows?

梦想的初衷 提交于 2019-12-30 07:23:09
问题 <table> <tr> <td>Row 1 Column1</td> <td>Row 1 Column2</td> </tr> <tr class="dynamicRows"> <td>Row 2 Column1</td> <td>Row 2 Column2</td> </tr> <tr class="dynamicRows"> <td>Row 3 Column1</td> <td>Row 3 Column2</td> </tr> <tr> <td>Row 5 Column1</td> <td>Row 5 Column2</td> </tr> </table> This is the Table Structure. I want to insert below Row <tr class="dynamicRows"> <td>Row 4 Column1</td> <td>Row 4 Column2</td> </tr> After the 3rd row I want to insert new row elements via Jquery at the end of

Any performance reason to put attributes protected/private?

大憨熊 提交于 2019-12-30 07:10:50
问题 I "learned" C++ at school, but there are several things I don't know, like where or what a compiler can optimize, seems I already know that inline and const can boost a little... If performance is an important thing (gaming programming for example), does putting class attributes not public ( private or protected ) allow the compiler to make more optimized code ? Because all my previous teacher were saying was it's more "secure" or "prevent not wanted or authorized class access/behavior", but

Members vs method arguments access in C++

[亡魂溺海] 提交于 2019-12-30 07:08:57
问题 Can I have a method which takes arguments that are denoted with the same names as the members of the holding class? I tried to use this: class Foo { public: int x, y; void set_values(int x, int y) { x = x; y = y; }; }; ... but it doesn't seem to work. Is there any way of accessing the the instance the namespace of which I'm working in, similar to JavaScript's this or Python's self ? 回答1: It's generally a good idea to avoid this kind of confusion by using a naming convention for member

Can an abstract class be member of other concrete class as composition relationship ? c++

谁说我不能喝 提交于 2019-12-30 06:58:33
问题 P is an abstract class, I want to make it member of class A which is a normal concrete class. Is it possible if yes how. Relationship is composition Thanks for help 回答1: Since P is abstract, you can never create an object of that type. However, you can store a pointer to P as a member of class A ; this pointer member could then point to an instance of a (concrete) subclass of P . 回答2: No. A composition relationship implies that class Client actually contains a member variable of type

Python : method resolution order of old-style (or classic) and new-style objects

早过忘川 提交于 2019-12-30 06:58:26
问题 I have read a lot about Objects in Python Documentation which differentiates these two at some point like: Old-style instances, independently of their class, are implemented with a single built-in type, called instance. A new-style class is neither more nor less than a user-defined type. Could anyone explain to me more on this "old-style (or classic) and new-style." I can not figure out what this line is trying to say : "For new-style classes, the method resolution order changes dynamically

Classes vs Activities in Android

落花浮王杯 提交于 2019-12-30 06:56:09
问题 I'm a beginner in Android development but not in programming itself. Anyway, this question might be a bit dumb. The question is: Are all classes in Android activities related to a UI element? I want to have a "regular" Java class from which i can normally create objects and i'm not figuring out how to "define it" and how to "call" it. Any help would be much appreciated. Thanks 回答1: Yes you can have regular classes and no they are not all related to a UI element. This works pretty much like

importing classes using wildcards

那年仲夏 提交于 2019-12-30 06:46:11
问题 If I say: import java.awt.event.ActionListener; I get the ActionListener Class. If I say: import java.awt.event.*; I get the event class including ActionListener? Or better yet: import java.awt.*; I thought that if you included a class, like in the last two example, that you effectively imported that class and inherited all of its subclasses. But, when I use only the last line, for example, Eclipse often shows errors saying it cannot resolve certain items and suggests I include both the java