class

What if an argument has the same name as that of a data member?

偶尔善良 提交于 2020-01-16 09:59:38
问题 #include <iostream> struct A { A(int n) { std::cout << n; } int n{2}; }; int main() { A a{1}; } The output is 1 rather than 2 . Does the C++ standard define that the argument name is preferred if it is the same as that of a data member? 回答1: The argument is in a "closer" scope than the member variable, so the argument shadows the member variable. The obvious solution is to rename the argument (or the member variable), so they are not the same anymore. You can also use this->n to explicitly

css 4种方法实现左右两侧固定 中间自适应布局

泪湿孤枕 提交于 2020-01-16 09:29:25
先来看一下最终效果: 代码: <!DOCTYPE html> < html lang = " en " > < head > < meta charset = " UTF-8 " > < meta name = " viewport " content = " width=device-width, initial-scale=1.0 " > < meta http-equiv = " X-UA-Compatible " content = " ie=edge " > < title > Document </ title > < style > .con { height : 200px ; background : #ccc ; margin-bottom : 10px ; } .con_l,.con_r { width : 200px ; height : 80% ; } .con_l { background : plum ; } .con_r { background : saddlebrown ; } .con_c { height : 100% ; background : slateblue ; } /* 1. float + bfc */ .con1_l { float : left ; } .con1_r { float : right ; } .con1_c

Nested Static classes Java [duplicate]

旧巷老猫 提交于 2020-01-16 09:06:34
问题 This question already has answers here : Error - Illegal static declaration in inner class (3 answers) Closed 4 days ago . I am a beginner to java. I was practicing java nested classes when I run the given problem. Oracle JDK 11.0.5 Problem:- Whenever I try to run the compiler for the following code I run across the given errors. public class test { public class Outer{ static int out1; public static void display1() { System.out.println("\n\nIn outer one!"); System.out.println(out1); } public

jQuery dynamic underlining

萝らか妹 提交于 2020-01-16 08:50:34
问题 I've got hidden divs that my navigation menu shows/hides. When showing/hiding the divs, the corresponding menu option is underlined; meaning the former div fades out, the current div fades in, and the underline follows. The underline does not hide when you close a div by re-clicking on its name in the menu. So ideally the underline will dynamically be added/removed following the dynamic div toggling. Thanks for your time and patience! HTML: <div id="nav"> <a class="home" id="show_brand" title

What is a parent/master that initialize a tkinter class?

戏子无情 提交于 2020-01-16 08:33:10
问题 Note The example code is an abridged version but can run with a basic function. Please focus on class MainWindow(tk.Frame) Questions What kind of object can play the role of the parent or master for tkinter class initialization? In my case, see the example code, why can not pass self as parent to ProjectInfo(...) or ConfirmItems(...) in class MainWindow(tk.Frame) ? It would pop up an empty window if using self instead of self.parent . Reference This question originates from my comments on

Are friend functions inherited? and why would a base class FRIEND function work on a derived class object?

ぐ巨炮叔叔 提交于 2020-01-16 05:26:27
问题 class baseClass { public: friend int friendFuncReturn(baseClass &obj) { return obj.baseInt; } baseClass(int x) : baseInt(x) {} private: int baseInt; }; class derivedClass : public baseClass { public: derivedClass(int x, int y) : baseClass(x), derivedInt(y) {} private: int derivedInt; }; in the function friend int friendFuncReturn(baseClass &obj) { return obj.baseInt; } I don't understand why would the friend function of the base class work for the derived class? should not passing derived

emberjs router class active

时光怂恿深爱的人放手 提交于 2020-01-16 04:51:44
问题 I know i can find examples of this but i cant put it into my code without errors... just dont know why. I want start with set class="menu-active" to first in menu. <li><a {{action gotoAbout}} >About</a></li> And later when somebody click other position of menu move class="menu-active" to this position. http://jsfiddle.net/kwladyka/LGArM/3/ And the bonus question: Do you have any remarks to make my code better? HTML <script type="text/x-handlebars" data-template-name="application"> {{view App

When do I want to declare interface over the actual class?

醉酒当歌 提交于 2020-01-16 04:38:28
问题 For example, I often see this: Set<Integer> s = new TreeSet<Integer>(); Set<Integer> s = new HashSet<Integer>(); Map<Integer, String> m = new HashMap<Integer, String>(); over TreeSet<Integer> ts = new TreeSet<Integer>(); HashSet<Integer> hs = new HashSet<Integer>(); HashMap<Integer, String> hm = new HashMap<Integer, String>(); What are the advantages/disadvanges of the former vs the latter? 回答1: For me it comes down to a number of points. Do you care about the implementation? Does your code

UITapGestureRecognizer calling another class

时光怂恿深爱的人放手 提交于 2020-01-16 03:18:09
问题 I am having an issue setting up a UITapGestureRecognizer calling a shared class across my app. Basically I have a bunch of images that if tapped will popup another view with that image and comments. Instead of using initWithTarget using self I want to call the function from a shared class that can be loaded into each type of Navigation Controller. I am able to initialize ImageClass *imageClass = [[ImageClass alloc]init] and call the functions fine by [imageClass DoThis] however when I add it

Error on CLLocation subclassing

守給你的承諾、 提交于 2020-01-16 00:46:53
问题 I'm trying to make a new CLLocation subclass. This is the skeleton: #import <UIKit/UIKit.h> #import <CoreLocation/CoreLocation.h> @interface JFLocation : CLLocation { } @end #import "JFLocation.h" @implementation JFLocation @end When I build the class I'm getting this errors: Undefined symbols: ".objc_class_name_CLLocation", referenced from: .objc_class_name_JFLocation in JFLocation.o ld: symbol(s) not found Any Idea?? Thank you!! 回答1: You should add CoreLocation.framework to the frameworks