I know that to create array in C++ use new []  and delete this array use delete []  I wonder if I create a object and delete this with delete []  Test * a = new Test; delete [] a;   Well... it works... but is it safe? should I use delete without bracket?
Alright, I think we all agree that what happens with the following code is undefined, depending on what is passed,  void deleteForMe(int* pointer) {      delete[] pointer; }   The pointer could be all sorts of different things, and so performing an unconditional delete[] on it is undefined. However, let's assume that we are indeed passing an array pointer,  int main() {      int* arr = new int[5];      deleteForMe(arr);      return 0; }   My question is, in this case where the pointer is an array, who is it that knows this? I mean, from the language/compiler's point of view, it has no idea whether or not arr is an array pointer versus a pointer to a single int. Heck, it doesn't even know whether arr was dynamically created. Yet, if I do the following instead,  int main() {      int* num = new int(1);      deleteForMe(num);      return 0; }   The OS is smart enough to only delete one int and not go on some type of 'killing spree' by deleting the rest of the memory beyond that point (contrast that with strlen and a non-\0-terminated string -- it will keep going until it hits 0).  So whose job is it to remember these things? Does the OS keep some type of record in the background? (I mean, I realise that I started this post by saying that what happens is undefined, but the fact is, the 'killing spree' scenario doesn't happen, so therefore in the practical world someone is remembering.)
I just refreshed the [iphone]-tag-site, and I'm seeing all kinds of questions with what appears to be a grey overlay (see image). What is this for/why am I seeing this? I have never seen anything like this before.. How to separate iMessages with shared Apple ID? My son and wife both have iPod Touches and I have an iPhone. We all used the same Apple ID and turned on iMessage. Both my son and wife were getting texts from my friends and my work on their iPods, I think because my cell phone number was linked to the Apple ID.  If I just turn off iMessage on my iPhone, will that solve the issue? Linux GUI development I have a large GUI project that I'd like to port to Linux. What is the most recommended framework to utilize for GUI programming in Linux? Are Frameworks such as KDE / Gnome usable for this objective  Or is better to use something more generic other than X?  I feel like if I chose one of Gnome or KDE, I'm closing the market out for a chunk of the Linux market who have chosen one over the other.  (Yes I know there is overlap)    Is there a better way? Or would I have to create 2 complete GUI apps to have near 100% coverage?  It's not necessary to have a cross-platform solution that will also work on Win32. How is the recommended next badge determined exactly? According to , the     "Progress to next badge" bar automatically selects the badge you're closest to earning (or that's most logical to go for next)   While "the badge you're closest to earning" is pretty easy to determine: it's the bar with the most progress, I'm wondering what "most logical to go for next" means. Because right now on Meta Stack Exchange, I can track two badges: Illuminator and Legendary. My progress for Illuminator is 66.40% and for Legendary it's 66.67%, yet Illuminator is shown as the recommended next badge:    On some child metas where I barely have any activity, Student is shown as recommended next badge with a progress of 0/1, but I do have cast some votes so I have a small progress towards e.g. Civic Duty. So obviously there is some other logic at work, but what? Which punctuation is correct in this case (colon, semicolon, or period)? Threshold Secret sharing - How to create a shared secret from pre existing secret parts? In usual $(t, n)$ secret sharing schemes, a secret $S$ is split into $n$ parts so that any $t$ out of $n$ parts reconstruct the original secret. So, suppose that there is a group of $n$ participants each one has a secret $x_i$ ($x_i$ may be its private key). My question is, is it possible to create a secret $S$ using the prexisting secrets $x_i$ ($i=1...n$) so that with any $t$ out of $n$ from these secrets ($x_i$) we can find the secret $S$? rstrip not removing newline char what am I doing wrong? How am I supposed to use nvidia-prime? I have an acer laptop with these GPUs: - GPU0: Intel HD Graphics 4000 (M) (obviously integrated) - GPU1: NVIDIA GeForce GT 710M  I uninstalled all nvidia-drivers because I was experiencing a lot of bugs and I read here and there that they are not supposed to work with Optimus without either bumblebee or nvidia-prime.  As far as I understand, nvidia-prime would allow me to have the NVidia GPU always on. And to choose between that or always off (i.e. always use Intel)  So now I installed nvidia-prime with  sudo apt-get install nvidia-prime   What am I supposed to do now?  I thought nvidia-prime provided a graphical interface which would allow me to choose which graphic card to use, and even to install the needed nvidia drivers.  By typing "nvidia" in the dash, nothing shows up. From a terminal, the only command available starting with "nvidia" is "nvidia-detect" which just prints "none".  So, I installed nvidia-prime, how do I use it? Significance of starting the Fibonacci sequence with 0, 1.... DISCLAIMER: I do not deal with in-depth mathematics on a daily basis as some of you may, so please pardon my ignorance or lack of coherence on this topic.  QUESTION: What is the significance of starting the Fibonacci sequence with $0,1$ ?  For instance, if I picked any two random integers, say 2 and 7, to start a sequence would I actually be creating some multiple or derivation of the Fibonacci sequence?  Is there a general mathematical explanation for the relationship between any sequence represented by $a[0] = x, a[1] = y, a[n] = a[n-1] + a[n-2]$ and the Fibonacci sequence?  Or, back to my example sequence, is there a general mathematical relationship between:  $2,7,9,16,25,41,66,107,173,280...$  and  $0,1,1,2,3,5,8,13,21,34...$  Perhaps the Golden Ratio explains it somehow?  Any help would be appreciated. Why do I get compiler errors with this Java code?  1  public List&lt;? extends Foo&gt; getFoos() 2  { 3    List&lt;? extends Foo&gt; foos = new ArrayList&lt;? extends Foo&gt;(); 4    foos.add(new SubFoo()); 5    return foos; 6  }  Where 'SubFoo' is a concrete class that implements Foo, and Foo is an interface.  Errors I get with this code:   On Line 3: "Cannot instantiate ArrayList&lt;? extends Foo&gt;" On Line 4: "The method add(capture#1-of ? extends Foo) in the type List&lt;capture#1-of ? extends Foo&gt; is not applicable for the arguments (SubFoo)"   Update: Thanks to Jeff C, I can change Line 3 to say "new ArrayList&lt;Foo&gt;();".  But I'm still having the issue with Line 4. Calculate a running total in MySQL I have this MySQL query:  SELECT DAYOFYEAR(`date`)  AS d, COUNT(*)  FROM  `orders`  WHERE  `hasPaid` &gt; 0 GROUP  BY d ORDER  BY d   Which returns something like this:  d  | COUNT(*) | 20 |  5       | 21 |  7       | 22 | 12       | 23 |  4       |   What I'd really like is another column on the end to show the running total:  d  | COUNT(*) | ??? | 20 |  5       |   5 | 21 |  7       |  12 | 22 | 12       |  24 | 23 |  4       |  28 |   Is this possible? Prezi is a proprietary software .   I found beamer, powerdot, HA -prosper, prosper, slides and seminar. Which one or something similar should I use to create something like Prezi-style zooming dia -presentation? Prove that $\mathbb{Z}[\omega]$ is an integral domain I was doing some re-tagging and I noticed that the automatically generated revision comment says that I edited the post body where I only edited the tags. I marinated chicken five days ago in lemon juice, seasoned salt, and garlic powder, is it still safe to cook in the oven? Unable to install any updates through update manager/apt-get upgrade I have been running Ubuntu 12.04 for the past few weeks. I recently tried to download and install some files through the Update Manager. It located a few files, downloaded them, but then failed to install them. It gave the error:  installArchives() failed: (Reading database ...  (Reading database ... 80% dpkg: unrecoverable fatal error, aborting:  reading files list for package 'libasn1-8-heimdal': Input/output error   I tried using apt-get upgrade but a similar error was produced:  Reading package lists... Done Building dependency tree        Reading state information... Done The following packages will be upgraded:   icedtea-6-jre-cacao icedtea-6-jre-jamvm openjdk-6-jre openjdk-6-jre-headless   openjdk-6-jre-lib 5 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. Need to get 0 B/34.6 MB of archives. After this operation, 1,024 B of additional disk space will be used. Do you want to continue [Y/n]? y (Reading database ... 80% dpkg: unrecoverable fatal error, aborting:  reading files list for package 'libasn1-8-heimdal': Input/output error E: Sub-process /usr/bin/dpkg returned an error code (2)   Any help would be greatly appreciated. Thanks in advance.  Edit: Here's some extra information that may be useful. My original problem was that the Ubuntu Software Centre would not open. I found that the Update Manager and Synaptic Package Manager also failed to open. They all gave an error along the lines of:   "installArchives() failed: dpkg: error: reading package info file '/var/lib/dpkg/available': Input/output errorError in function:"   After much googling I seemed to fix that problem as the package managers would open again. When I then tried to download and install any updates from the Update Manager I got the error at the beginning of this post. What Scoping Class Will  Use? In reading through the release notes I was excited to discover the introduction of a new  tag. That should help lower the barriers to entry! However, the release notes do not specify what the name of the scoping class should be. And since , we're left guessing.  To be explicit about what I'm trying to understand, take  for example:  &lt;apex:page showHeader="false" standardStylesheets="false" sidebar="false" applyHtmlTag="false" applyBodyTag="false" docType="html-5.0"&gt;     &lt;html xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" lang="en"&gt;         &lt;head&gt;             ...             &lt;apex:stylesheet value="{!URLFOR($Resource.REPLACE_WITH_NAME_OF_SLDS_STATIC_RESOURCE, 'assets/styles/salesforce-lightning-design-system-vf.min.css')}" /&gt;         &lt;/head&gt;         &lt;body&gt;              &lt;!-- REQUIRED SLDS WRAPPER --&gt;             &lt;div class="REPLACE_WITH_NAME_OF_CUSTOM_SCOPING_CLASS"&gt;             ...         &lt;/body&gt;     &lt;/html&gt; &lt;/apex:page&gt;   If I replace the &lt;apex:stylesheet&gt; with &lt;apex:slds&gt;, what should I specify for REPLACE_WITH_NAME_OF_CUSTOM_SCOPING_CLASS? Prove $\sqrt{2}$ is between $\dfrac{a}{b}$ and $\dfrac{a+2b}{a+b}$ Let $a$ and $b$ be positive integers. Show that $\sqrt{2}$ always lies between $\dfrac{a}{b}$ and $\dfrac{a+2b}{a+b}$.  Please give the easy solution as possible. set of almost complex structures on $\mathbb R^4$ as two disjoint spheres The set of almost complex structures on $\mathbb R^{2n}$ is given by $$ M_n = \frac{GL(2n,\mathbb R)}{GL(n,\mathbb C)} = \mathcal C_+ \sqcup \mathcal C_-,$$ taking into account that $\det = \pm 1$ gives two disjoint sets.  How do we show that $M_2=S^2 \sqcup S^2$? Moreover, I'm a bit confused by dimensions: how does $\dim_{\mathbb R}M_2=8$ relates with the latter decomposition?  This is exercise 1.2.1 from the book Complex geometry by Huybrechts. No more WIFI. oem-wifi-intel-iwlwifi doesn't build on the new 4.4 kernel