Why do we need virtual functions in C++?

Why do we need virtual functions in C++?

I'm learning C++ and I'm just getting into virtual functions.From what I've read (in the book and online), virtual functions are functions in the base class that you can override in derived classes.But earlier in the book, when learning abo

Understanding kwargs in Python

Understanding kwargs in Python

What are the uses for **kwargs in Python?I know you can do an objects.filter on a table and pass in a **kwargs argument. Can I also do this for specifying time deltas i.e. timedelta(hours = time1)? How exactly does it work? Is it classes as

Unique (non-repeating) random numbers in O(1)?

Unique (non-repeating) random numbers in O(1)?

I'd like to generate unique random numbers between 0 and 1000 that never repeat (i.e. 6 doesn't show up twice), but that doesn't resort to something like an O(N) search of previous values to do it. Is this possible? 1:Initialize an array

How to “properly” create a custom object in JavaScript?

How to “properly” create a custom object in JavaScript?

I wonder about what the best way is to create an JavaScript object that has properties and methods.I have seen examples where the person used var self = this and then uses self. in all functions to make sure the scope is always correct.Then

Converting ISO 8601-compliant String to java.util.Date

Converting ISO 8601-compliant String to java.util.Date

I am trying to convert an ISO 8601 formatted String to a java.util.Date. I found the pattern "yyyy-MM-dd'T'HH:mm:ssZ" to be ISO8601-compliant if used with a Locale (compare sample).However, using the java.text.SimpleDateFormat, I cannot con

What is a StackOverflowError?

What is a StackOverflowError?

What is a StackOverflowError, what causes it, and how should I deal with them? 1:Parameters and local variables are allocated on the stack (with reference types the object lives on the heap and a variable references that object). The sta

Non-static variable cannot be referenced from a static context

Non-static variable cannot be referenced from a static context

I've written this test code:class MyProgram{ int count = 0; public static void main(String[] args) { System.out.println(count); }}But it gives the following error:Main.java:6: error: non-static variable count cannot be re

Tail recursion on R Statistical Environment

Tail recursion on R Statistical Environment

Does R support proper tail recursion and where can I find documentation about this? 1:It's quite easy to find out that R does not support tail recursion optimization:f Had tail calls been optimized to jumps, then this function would have

Android API to check if call is Active or On Hold

Android API to check if call is Active or On Hold

Is there an API function to check if a call is currently Active, or if has been put on Hold?Assuming I have two connected calls, is there a way to check if each one is active, on-hold, or maybe they are connected in a conference call? 1:

How to show Alert Message like “successfully Inserted” after inserting to DB using ASp.net MVC3

How to show Alert Message like “successfully Inserted” after inserting to DB using ASp.net MVC3

How to write a code for displaying the alert message: "Successfully registered", after user data is stored in database, using MVCI am using Asp.Net MVC3, C#, Entity Model. 1:Try using TempData:public ActionResult Create(FormCollection co

What is the synchronization cost of calling a synchronized method from a synchronized method?

What is the synchronization cost of calling a synchronized method from a synchronized method?

Is there any difference in performance between thissynchronized void x() { y();}synchronized void y() {}and thissynchronized void x() { y();}void y() {} 1:Yes, there is an additional performance cost, unless and until the JVM inlin

Android EditText alternative

Android EditText alternative

Currently, Android's EditText is extremely slow when dealing with a huge amount of lines of text (10000+). It appears like this slowdown is partially due to the fact that EditText supports spans, and primarily due to the fact that EditText

Getting Nested Object Property Value Using Reflection

Getting Nested Object Property Value Using Reflection

I have the following two classes:public class Address{ public string AddressLine1 { get; set; } public string AddressLine2 { get; set; } public string City { get; set; } public string State { get; set; } public string Zip { g

Rhino Mocks stubs and mocks are only good for interfaces?

Rhino Mocks stubs and mocks are only good for interfaces?

Is it correct that Rhino Mocks stubs and mocks are only good for interfaces, not concrete classes? I spent quite a time trying to make this piece of code working. I did not expect the stubbed pubSubClient to always call Send method from the

Same named function with multiple arguments in PHP

Same named function with multiple arguments in PHP

I started off OOP with Java, and now I'm getting pretty heavy into PHP. Is it possible to create multiples of a function with different arguments like in Java? Or will the interpreted / untyped nature of the language prevent this and cause

Why are generic and non-generic structs treated differently when building expression that lifts oper

Why are generic and non-generic structs treated differently when building expression that lifts oper

This looks like a bug in lifting to null of operands on generic structs.Consider the following dummy struct, that overrides operator==:struct MyStruct{ private readonly int _value; public MyStruct(int val) { this._value = val; } pu

Multiple gesture responders at the same time

Multiple gesture responders at the same time

I need some buttons that can be pressed at the same time, but currently if you press one, it 'claims' responsiveness and the others can't be pressed anymore. How do I do this? 1:Got it. You have to use ReactNativeEventEmitter to directly

HTTP basic authentication not working in python 3.4

HTTP basic authentication not working in python 3.4

I am trying to login to a REST API using HTTP Basic Authentication but it is not working and giving the errorHTTP error 400: Bad RequestHere is my code:import urllib.parseimport urllib.requestimport urllib.response# create an authorization

Why can't I return arbitrary array of string?

Why can't I return arbitrary array of string?

The compiler allows me to do the following:procedure MyProc(const ADynData: array of string);orprocedure MyProc(const ADynData: TStringDynArray);and pass arbitrary data like so:MyProc(['Data1', 'Data2']);However, won't allowfunction MyFunc:

Converting recursive permutation generator to iterative

Converting recursive permutation generator to iterative

I'm having some difficulty converting this recursive algorithm for displaying all the permutations of a given set of integers into an iterative one.void getPermutationsR(int v[], int n, int i) { if (i == n) { //Display contents

PDF Manipulation on iPhone SDK

PDF Manipulation on iPhone SDK

I have been reading Apple's docs and they recommend using UIWebView. This is all well and good until you want to go to a page number and also search PDF's.Is there any 3rd Party libraries, (free or paid) that do this at all? As a minimum

How to keep NSTimer alive in Background on iOS 7?

How to keep NSTimer alive in Background on iOS 7?

I have created Application which runs NSTimer in Background. I used the Location manager to run the NSTimer in background,I used below link to run NSTimer in background,How do I get a background location update every n minutes in my iOS app

Declaring and Using Global Arrays c#

Declaring and Using Global Arrays c#

I couldn't find any information pertaining to this question. I am trying to create a global array in C# so that I can input information into it at different points in my code and then call the information back at a later time to display it.

FragmentStatePagerAdapter onPageSelected event

FragmentStatePagerAdapter onPageSelected event

I have a FragmentStatePagerAdapter with 6 fragments inside.Each Fragment connect's to the server and loads data.Right now, the server connection is being done in Fragment.onStart(), that means that at any moment, I have 3 http requests goin

Android IRC Office Hours Question About Android Bluetooth RSSI

Android IRC Office Hours Question About Android Bluetooth RSSI

I have a question about bluetooth RSSI functionality on the Android (either 2.0 or 2.1):It's easy enough to get the RSSI value when a bluetooth connection is created, but how can you repeatedly get the RSSI value of a connection that is alr