In one of my classes at school, part of my assignment includes creating a constructor that assigns random values into a 2D array. While I have been able to create the array, have the constructor assign random values into said array, I cannot seem to create multiple objects with different 2D arrays. Any object I make seems to hold the same values previously assigned to the first one. I am fairly new at c++ so I assume the answer is barely flying over my head. TIA  #include &lt;ctime&gt; #include &lt;cstdlib&gt; #include &lt;iostream&gt;  using namespace std;  const int sizeOfArray = 3; int myArray;//a  class Matrix { public:   int myArray[sizeOfArray][sizeOfArray];//a   Matrix ()//b   {     srand(time(NULL));     for(int i = 0; i &lt; sizeOfArray; i++){       for(int j = 0; j &lt; sizeOfArray; j++){       myArray[i][j] = rand() % 10;       }     }   }    void printMyArray();  }; void Matrix::printMyArray()//c {   cout&lt;&lt;"The Matrix is as follows: \n"&lt;&lt;endl;   cout&lt;&lt;myArray[0][0]&lt;&lt;"\t"&lt;&lt;myArray[0][1]&lt;&lt;"\t"&lt;&lt;myArray[0][2]&lt;&lt;"\n"&lt;&lt;endl;   cout&lt;&lt;myArray[1][0]&lt;&lt;"\t"&lt;&lt;myArray[1][1]&lt;&lt;"\t"&lt;&lt;myArray[1][2]&lt;&lt;"\n"&lt;&lt;endl;   cout&lt;&lt;myArray[2][0]&lt;&lt;"\t"&lt;&lt;myArray[2][1]&lt;&lt;"\t"&lt;&lt;myArray[2][2]&lt;&lt;"\n"&lt;&lt;endl; }  int main() {   Matrix matrix;   matrix.printMyArray();    Matrix natrix;   natrix.printMyArray();    return 0; }   I want the output to spit out two different arrays, however, the same array is repeated twice with the output as:   The Matrix is as follows:  4   0   9  6   0   4  6   3   0  The Matrix is as follows:  4   0   9  6   0   4  6   3   0
I need a 'good' way to initialize the pseudo-random number generator in C++. I've found  that states:     In order to generate random-like   numbers, srand is usually initialized   to some distinctive value, like those   related with the execution time. For   example, the value returned by the   function time (declared in header   ctime) is different each second, which   is distinctive enough for most   randoming needs.   Unixtime isn't distinctive enough for my application. What's a better way to initialize this? Bonus points if it's portable, but the code will primarily be running on Linux hosts.  I was thinking of doing some pid/unixtime math to get an int, or possibly reading data from /dev/urandom.  Thanks!  EDIT  Yes, I am actually starting my application multiple times a second and I've run into collisions.
I've read  and am interested in this line:     You should never use normal sudo to start graphical applications as Root.   Why? What is the difference? Please provide a simple explanation, as I'm just a normal desktop user. Allow moderators to see delete/undelete activity on users' profiles We get auto flags for 'possible vandalism' related to deletes, and these can be helpful at times in finding 'rage quit' users, or other potential problems.  But often, I would like to know if there is a prior pattern with the user doing this. While we can see posts of theirs which have been flagged, and perhaps find previous auto flags this way, it would be nice to see an overall view of their self-deletions and undeletions; mostly just to identify patterns.  Such a feature would be nice if it was activity centered, rather than post-centered. That is; each delete/undelete action should be shown. So we could easily see, for example, if someone went back-and-forth on a single post.  The "activity" tab in the profile would be a logical place to show these events.  I think this would be best to be limited to instant self-deletions, not deletion votes. brute force password guessing on SSH server isn't going to work? I'm running an SSH server on my personal computer. The log had many people(or bots?) repeatedly trying to log in to my server (that is before I changed the default port), which made me a little freaked out. I was worried about their dictionary attacks or brute force password guessing.  But then if you type wrong password (or wrong username), the server waits for about 2 seconds before it asks for password again. So an attacker can try one password per 2 seconds. So I concluded that these attacks aren't that great a threat (as long as your password does not consist of dictionary words.) Am I correct? Direction arrows on a circle I would like to plot circle (or another curve) with positive direction (and show it wit arrows).  This plots the circle  \documentclass{article} \usepackage{tikz} \RequirePackage{pgfplots} \usetikzlibrary{shadows} \usetikzlibrary{shapes} \usetikzlibrary{decorations} \usepackage{verbatim} \usepackage[active,tightpage]{preview} \PreviewEnvironment{tikzpicture} \setlength\PreviewBorder{5pt} \begin{document} \begin{tikzpicture}     \begin{axis}[             xmin=-1.5,xmax=2.5,ymin=-1.5,ymax=1.5,             axis lines=center,             ticks=none,             unit vector ratio*=1 1 1,            ]                   \addplot [very thick, smooth, domain=(0:2*pi)] ({1.+cos(deg(x))},{sin(deg(x))});        \addplot[only marks,mark=*] coordinates{(1,0)};         \end{axis} \end{tikzpicture} \end{document}   And I want to add arrows like that    Would you advise me how to add such arrows? Evaluating $\lim\limits_{n\to\infty}(a_1^n+\dots+a_k^n)^{1\over n}$ where $a_1 \ge \cdots\ge a_k \ge 0$ Need to find $\lim\limits_{n\to\infty}(a_1^n+\dots+a_k^n)^{1\over n}$ Where $a_1\ge\dots\ge a_k\ge 0$  I thought about Cauchy Theorem on limit $\lim\limits_{n\to\infty}\dfrac{a_1+\dots+a_n}{n}=\lim a_n$ and something like what happen if all $a_i=0$ or $a_1=\dots=a_k$, but may be something I am thinking wrong?  Maybe it is too simple but I am not getting it; please help. Acne underneath skin Introduction  Okay, I've almost won my war. The battle, its almost won... However, I must still claim victory in my final battle. The battle against the little enemies, the ones that have fought with my blade of benzoyl peroxide every single day.  Problem  Through spot treatments I have been able to fell every single one of these spots, but only the ones on my face. I've been using a spot treatment with benzoyl peroxide in, which has worked really well for me. However, my issue comes here:     There are spots underneath my skin, I think. The areas where they come through are a bit red.   So, because there is still slightly red skin on my face, and I think this is causing my acne to constantly return. I need to stop this, and end my war once and for all.  What I've tried   Washing my face with a rag and sponge every day, three times a day Changing my pillow case every day Using a benzoyl peroxide spot treatment Minimizing how much I touch my face Not interfering with the spots with my fingers, not picking at them, not playing with them. Just letting spot creams eradicate them.   Conclusion  Seriously, this driving me up the wall. I spot cream in the evening, by the time tomorrow has ended and its time for a shower, they've all come back. Its like they're coming in waves, damn waves! I must put an end to this.  So, how can I prevent acne from coming back within the space of a single school day? How can I get rid of these once and for all? What types of measures could I try? I have no reason to visit my doctor, its only acne, but I have no idea what I can try now.  Is there even a point in me trying? I acknowledge that I am a teenager, but no others that I know seem to have acne/spots like I do. Find the almost sure limit of $X_n/n$, where each random variable $X_n$ has a Poisson distribution with parameter $n$ $X_{n}$ independent and $X_n \sim \mathcal{P}(n) $  meaning that $X_{n}$ has Poisson distributions with parameter $n$. What is the $\lim\limits_{n\to \infty} \frac{X_{n}}{n}$ almost surely ?    I think we can write $X(n) \sim X(1)+X(1)+\cdots+X(1)$ where the sum is taken on independent identical distribution then use the law of large number. But I am not sure that is it correct or not. Can anyone give me some hints? Thank you in advance! Well, the original task was to figure out what the following expression evaluates to for any $n$.  $$\begin{pmatrix} 1 &amp; 1 \\ 0 &amp; 1\end{pmatrix}^{\large n}$$  By trying out different values of $n$, I found the pattern: $$\begin{pmatrix} 1 &amp; 1 \\ 0 &amp; 1\end{pmatrix}^{\large n} = \begin{pmatrix} 1 &amp; n \\ 0 &amp; 1\end{pmatrix}$$  But I have yet to figure out how to prove it algebraically.   Suggestions? I've been using the Linksys USB6300 Adapter but when I switched to Ubuntu it stopped working since its only compatible with Windows. I've tried using ndiswrapper and although it says my windows driver is installed, my device isn't showing up. Anyone know how I could get this wireless network adapter working? Thanks.  lsusb  Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub Bus 001 Device 012: ID 05c6:6766 Qualcomm, Inc.  Bus 001 Device 006: ID 0bda:0153 Realtek Semiconductor Corp. Mass Storage Device Bus 001 Device 005: ID 05e3:0608 Genesys Logic, Inc. USB-2.0 4-Port HUB Bus 001 Device 004: ID 04ca:007d Lite-On Technology Corp.  Bus 001 Device 003: ID 04ca:008a Lite-On Technology Corp.  Bus 001 Device 010: ID 13b1:003f Linksys  Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub wp_delete_auto_drafts() deletes links in menus Since yesterday the wp_scheduled_auto_draft_delete cron job somehow deletes all page entries from our menus. All entries in the table wp_postmeta with meta_key = '_menu_item_object' and meta_value = 'page' get deleted in the process. By tracing back the DELETE query I found out that the menu entries are deleted by a function called _wp_delete_post_menu_item. I got the following stacktrace for that function:  #0  _wp_delete_post_menu_item(3244) #1  call_user_func_array(_wp_delete_post_menu_item, Array ([0] =&gt; 3244)) called at [/srv/www/htdocs/biva/wp-includes/plugin.php:470] #2  do_action(delete_post, 3244) called at [/srv/www/htdocs/biva/wp-includes/post.php:2483] #3  wp_delete_post(3244, 1) called at [/srv/www/htdocs/biva/wp-includes/post.php:5645] #4  wp_delete_auto_drafts() #5  call_user_func_array(wp_delete_auto_drafts, Array ()) called at [/srv/www/htdocs/biva/wp-includes/plugin.php:546] #6  do_action_ref_array(wp_scheduled_auto_draft_delete, Array ()) called at [/srv/www/htdocs/biva/wp-cron.php:100]   But I'm stuck here, I'm not a wordpress developer and I have no clue why deleting old drafts results in deleting attached menu entries although the main pages still exist.  Workaround: As a workaround we added the following to the top of wp-config, wich will disable wp-cron:  /** Disable wp-cron to prevent menu from getting deleted. Detailed Bug description: http://wordpress.stackexchange.com/questions/145953 **/ define('DISABLE_WP_CRON', true);   If you are experiencing similar difficulties you might try locking the rows in the table wp_postmeta with meta_key = '_menu_item_object' and meta_value = 'page' and then tracing back the error message when WP trys to delete these rows, that's how we nailed down our error.  Reproduce the Error: It is definitely the stealth publish plugin that is causing our error, one can easily reproduce it, by doing the following:   Install a fresh Wordpress 3.9.1. Install the stealth publish plugin . Create a few test pages and add them to a new menu. Create a new page, with some dummy content, but do not save it!. Leave the page without saving. Change the system time 8 days into the future. The wp_scheduled_auto_draft_delete cron job will run because it runs daily and it hasn't run for 7 days as soon as you visit your page. It will then find your never saved dummy page delete it as it is older than 7 days and the menu will vanish. You might need to refresh the page a few times till the effect becomes visible.   I've recorded a screencast on how to reproduce the error (but I took not the time to comment it): How to manage and restore a modern iPhone or iDevice on ubuntu with iTunes This question—how to install iTunes on ubuntu—has been asked many times before on this site, but the answers are all outdated and involve Wine or some other tool that no longer works for the most recent version of iTunes. Put simply, I need to regularly back up and occasionally restore the firmware on an iPhone 6.   I cannot:   dual boot Windows—for some reason installing one OS makes the other unbootable &amp; after days of headache &amp; dozens of reinstalls I’ve decided to just leave Ubuntu be &amp; not try to preserve Windows. Plus “just use Windows” is not really a solution on an Ubuntu forum. use libimobiledevice-dev. libimobiledevice-dev doesn’t let you manage iOS updates or sync music anymore. Buy another phone. This one should be obvious but for some reason some asshat always comments “too bad lmao shouldntve bought an iphone ;P”. What tool do I need to install to make my terminal show the autocompletion of the command that I'm writing? Drawing a square root spiral I have a multiboot system set up. The system has three drives. Multiboot is configured with Windows XP, Windows 7, and Ubuntu - all on the first drive. I had a lot of unpartitioned space left on the drive and was reserving it for adding other OSes and for storing files there in the future.  One day I went ahead and downloaded Partition Wizard and created a logical NTFS partition from within Windows 7, still some unpartitioned space left over. Everything worked fine, until I rebooted the computer a few days later.  Now I'm getting:    error: unknown filesystem.   grub rescue&gt;   First of all I was surprised not to find any kind of help command, by trying:    help, ?, man, --help, -h, bash, cmd, etc.  Now I'm stuck with non-bootable system. I have started researching the issue and finding that people usually recommend to boot to a Live CD and fix the issue from there. Is there a way to fix this issue from within grub rescue without the need for Live CD?  UPDATE  By following the steps from , I was able to boot to initramfs prompt. But not anywhere further than that.  So far from reading the manual on , I was able to see my drives and partitions using ls command. For the first hard drive I see the following: (hd0) (hd0,msdos6) (hd0,msdos5) (hd0,msdos2) (hd0,msdos1)  I now know that (hd0,msdos6) contains Linux on it, since ls (hd0,msdos6)/ lists directories. Others will give "error: unknown filesystem."  UPDATE 2  After the following commands I am now getting to the boot menu and can boot into Windows 7 and Ubuntu, but upon reboot I have to repeat these steps.    ls ls (hd0,msdos6)/ set root=(hd0,msdos6) ls / set prefix=(hd0,msdos6)/boot/grub insmod /boot/grub/linux.mod normal   UPDATE 3  Thanks Shashank Singh, with your instructions I have simplified my steps to the following. I have learned from you that I can replace msdos6 with just a 6 and that I can just do insmod normal instead of insmod /boot/grub/linux.mod. Now I just need to figure out how to save this settings from within grub itself, without booting into any OS.  set root=(hd0,6) set prefix=(hd0,6)/boot/grub insmod normal normal   UPDATE 4  Well, it seems like it is a requirement to boot into Linux. After booting into Ubuntu I have performed the following steps described in the :  sudo update-grub sudo grub-install /dev/sda   This did not resolve the issue. I still get the grub rescue prompt. What do I need to do to permanently fix it?  I have also learned that drive numbers as in hd0 need to be translated to drive letters as in /dev/sda for some commands. hd1 would be sdb, hd2 would be sdc, and so on. Partitions listed in grub as (hd0,msdos6) would be translated to /dev/sda6.  UPDATE 5  I could not figure out why the following did not fix grub:  sudo update-grub sudo grub-install /dev/sda   So I downloaded  based on an answer from  post. That seemed to do the trick after I picked the "Recommended Repair (repairs most frequent problems)" option. Significance of $\sqrt[n]{a^n} $?! There is a formula given in my module:  $$ \sqrt[n]{a^n} = \begin{cases}  \, a  &amp;\text{ if $n$ is odd } \\  |a| &amp;\text{ if $n$ is even } \end{cases} $$  I don't really understand the differences between them, kindly explain with an example. $\mathbb{R}$ with the lower limit topology is not second-countable I am trying to prove that $\mathbb{R}$ with the lower limit topology is not second-countable.  To do this, I'm trying to form an uncountable union $A$ of disjoint, half-open intervals of the form $[a, b)$, $a &lt; b$. Is this possible? I think this would imply the $A$ is open but no countable union of basis elements could coincide with $A$ therefore making the real numbers with the lower limit topology not second-countable.  I think there must exist something like $A$ described above but I am having trouble visualizing it and coming up with a formula to represent it.  Maybe there is some other way to show it is not second-countable. Electric circuits in TeX, LaTeX, and Friends Reset the password in Ubuntu / Linux Bash in Windows I have installed Linux Bash on Windows 10 (available from Microsoft), but I've forgotten my password.  I've searched for a solution but I only find suggestions that involve doing something before the system boots, like accessing recovery mode, but that will not work in this case as this Ubuntu is just an application within a Windows system and doesn't have its own boot process.  How can I reset my password? What is the difference between the Circle-K and Lawson Power Cube? Add and remove update channels in an easy terminal way I know there is a GUI in Ubuntu Software &amp; Updates to enable the update channels   updates proposed backports security   as shown in this screenshot:    I am looking for an easy way to do this from within a terminal using commands such as    sudo apt-add-update enable updates sudo apt-add-update enable proposed sudo apt-add-update enable backports sudo apt-add-update enable security  sudo apt-add-update disable updates sudo apt-add-update disable proposed sudo apt-add-update disable backports sudo apt-add-update disable security   and an additional thing  sudo apt-add-update enable default  sudo apt-add-update disable default     Some examples for a better understanding   An empty sources.list   cat /etc/apt/sources.list  &lt;empty&gt;  sudo apt-add-update enable security  &lt;empty&gt;   One enabled repository (main)   cat /etc/apt/sources.list  deb http://archive.ubuntu.com/ubuntu wily main  sudo apt-add-update enable security  deb http://archive.ubuntu.com/ubuntu wily main deb http://archive.ubuntu.com/ubuntu wily-security main   Two or more enabled repositories in one or two lines   cat /etc/apt/sources.list  deb http://archive.ubuntu.com/ubuntu wily main universe   or   deb http://archive.ubuntu.com/ubuntu wily main deb http://archive.ubuntu.com/ubuntu wily universe  sudo apt-add-update enable security  deb http://archive.ubuntu.com/ubuntu wily main universe deb http://archive.ubuntu.com/ubuntu wily-security main universe   or  deb http://archive.ubuntu.com/ubuntu wily main deb http://archive.ubuntu.com/ubuntu wily-security main deb http://archive.ubuntu.com/ubuntu wily universe deb http://archive.ubuntu.com/ubuntu wily-security universe   With deb-src entries   cat /etc/apt/sources.list  deb http://archive.ubuntu.com/ubuntu wily main universe deb-src http://archive.ubuntu.com/ubuntu wily main universe  sudo apt-add-update enable security  deb http://archive.ubuntu.com/ubuntu wily main universe deb-src http://archive.ubuntu.com/ubuntu wily main universe deb http://archive.ubuntu.com/ubuntu wily-security main universe deb-src http://archive.ubuntu.com/ubuntu wily-security main universe   With inactive deb-src entries   cat /etc/apt/sources.list  deb http://archive.ubuntu.com/ubuntu wily main universe # deb-src http://archive.ubuntu.com/ubuntu wily main universe  sudo apt-add-update enable security  deb http://archive.ubuntu.com/ubuntu wily main universe # deb-src http://archive.ubuntu.com/ubuntu wily main universe deb http://archive.ubuntu.com/ubuntu wily-security main universe   The default thing    cat /etc/apt/sources.list  deb http://archive.ubuntu.com/ubuntu wily-security universe  sudo apt-add-update enable default  deb http://archive.ubuntu.com/ubuntu wily universe deb http://archive.ubuntu.com/ubuntu wily-security universe   Only one entry and the disable action   cat /etc/apt/sources.list  deb http://archive.ubuntu.com/ubuntu wily-security universe  sudo apt-add-update disable security  &lt;empty&gt;   Different or the same servers for different or the samerepositories, respect each server   cat /etc/apt/sources.list  deb http://archive.ubuntu.com/ubuntu wily universe deb http://us.archive.ubuntu.com/ubuntu wily main  sudo apt-add-update enable security  deb http://archive.ubuntu.com/ubuntu wily universe deb http://us.archive.ubuntu.com/ubuntu wily main deb http://archive.ubuntu.com/ubuntu wily-security universe deb http://us.archive.ubuntu.com/ubuntu wily-security main   Different Ubuntu releases for different repositories, respect each release   cat /etc/apt/sources.list  deb http://archive.ubuntu.com/ubuntu wily main universe deb http://archive.ubuntu.com/ubuntu trusty main  sudo apt-add-update enable security  deb http://archive.ubuntu.com/ubuntu wily main universe deb http://archive.ubuntu.com/ubuntu trusty main deb http://archive.ubuntu.com/ubuntu wily-security main universe deb http://archive.ubuntu.com/ubuntu trusty-security main   PPAs or other package sources (not-Canonical)  in the sources.list?  Ignore! Don't change the protocols, e.g. https, http, tor, ...