I get that you need pointers for handling something that grows and shrinks dynamically. In instances where that isn't the case, to my understanding, you use pointers when: your object is too big to be stored on the stack, or when you would like a function to modify data outside of its scope (why not just use references here?). Is this line of thinking correct? Other uses I can think of are for polymorphism and forward declarations. The other example people always give is pointer arithmetic and handling array indices, but then why not just use C++ iterators which just wrap pointers... Are there any other (common) cases? I used to think that pointers were useful as they allowed for objects to be passed around without the need for a full copy to be made, but surely move semantics allow you to accomplish that without the need for handling pointers? Overall, I feel like I am using too many unnecessary pointers in my codebase and I would really appreciate it if someone could definitively clear things up.
I know this is a really basic question, but I've just started with some basic C++ programming after coding a few projects with high-level languages.   Basically I have three questions:   Why use pointers over normal variables? When and where should I use pointers? How do you use pointers with arrays?
A cashier wants to work five days a week, but he wants to have at least one of the Saturday and Sunday off.  In how many ways can he choose the days he will work?  So, in this case, what should I count first?  How do I start?  I know how to solve this if the cashier doesn't want a weekend off, but what do I do if the cashier do?  Thanks! Output URL of open firefox tabs in terminal How do I eliminate the vertical realignment when using arrayrulecolor with cmidrule? What's the cleanest, most effective way to validate decimal numbers in JavaScript?  Bonus points for:   Clarity. Solution should be clean and simple. Cross-platform.   Test cases:  01. IsNumeric('-1')      =&gt; true 02. IsNumeric('-1.5')    =&gt; true 03. IsNumeric('0')       =&gt; true 04. IsNumeric('0.42')    =&gt; true 05. IsNumeric('.42')     =&gt; true 06. IsNumeric('99,999')  =&gt; false 07. IsNumeric('0x89f')   =&gt; false 08. IsNumeric('#abcdef') =&gt; false 09. IsNumeric('1.2.3')   =&gt; false 10. IsNumeric('')        =&gt; false 11. IsNumeric('blah')    =&gt; false Fixed point, union of $\aleph_0, \aleph_{\aleph_0},\aleph_{\aleph_{\aleph_0}}\dots$ [see Noah's comment on notation] Given that $f:[0,1]\to \Bbb{R}$ is a continuous function, I need to show that $$\lim_{n \to \infty}\prod_{k=1}^{n}\left(1+\frac{1}{n}f\left(\frac{k}{n}\right)\right)=e^{\int_0^1f(x)dx}$$  Writing $$y=\lim_{n \to \infty}\prod_{k=1}^{n}\left(1+\frac{1}{n}f\left(\frac{k}{n}\right)\right)$$ and taking the logarithm of both sides and interchanging limit and logarithm(since $f$ is continuous), I get $$\log y = \lim_{n\to \infty}\sum_{k=1}^{n}\log\left(1+\frac{1}{n}f\left(\frac{k}{n}\right)\right)$$ Now I know that the limit of the Riemann sum $\lim_{n\to \infty}\sum_{k=1}^{n}\frac{b-a}{n}f\left(a+\frac{(b-a)}{n}k\right)=\int_a^bf(x)dx$. However if I want it to read $\int_0^1f(x)dx$ in the given problem, I would need the term inside the summation to read $\frac{1}{n}f\left(\frac{k}{n}\right)$. The way to do this it would seem is to take the series expansion of $\log(1+x)$ and ignoring the $x^2$ and higher order terms. Is it justifiable to do so? Consider the subset $B=\{(x,y):x^2+y^2\leq 1\}\ \subseteq \mathbb{R}^2$. Show that $\vert B \vert = \vert \mathbb{R}^2 \vert$.  It is easy to see tht $f:B\rightarrow\mathbb{R}^2$ defined as $f(x,y)=(x,y)$ is injective.   However, in the book I'm working out of (Book of Proof by Richard Hammack), the other injection noted is  $g:\mathbb{R}^2\rightarrow B$ defined as  $$g(x,y)=\left(\frac{x^2+y^2}{x^2+y^2+1}x,\frac{x^2+y^2}{x^2+y^2+1}y\right).$$  In the book I'm asked to verify this is indeed an injective function.  My approach was to assume $g(x,y)=g(m,n)$ and through basic algebra I was able to deduce  $x(m^2+n^2+1)(x^2+y^2)=m(x^2+y^2+1)(m^2+n^2)$  and  $y(m^2+n^2+1)(x^2+y^2)=n(x^2+y^2+1)(m^2+n^2)$  but how does this show $(x,y)=(m,n)$? Or is this the wrong approach? Is the density operator a mathematical convenience or a 'fundamental' aspect of quantum mechanics? In quantum mechanics, one makes the distinction between mixed states and pure states.  A classic example of a mixed state is a beam of photons in which 50% have spin in the positive $z$-direction and 50% have spin in the positive $x$-direction.  Note that this is not the same as a beam of photons, 100% of which are in the state $$ \frac{1}{\sqrt{2}}[\lvert z,+\rangle + \lvert x,+\rangle]. $$ It seems, however, that at least in principle, we could describe this beam of particles as a single pure state in a 'very large' Hilbert space, namely the Hilbert space that is the tensor product of all the $\sim 10^{23}$ particles (I think that's the proper order of magnitude at least).  So then, is the density operator a mathematical convenience, or are there other aspects of quantum mechanics that truly require the density operator to be a 'fundamental' object of the theory?  (If what I mean by this is at all unclear, please let me know in the comments, and I will do my best to clarify.) Custom related list button is not working in partner portal I have created custom button called "New Employee" on employee object and it is related with both account and contact objects via lookup relation. If i click on "New Employee" button on employee related list under Account detail page, working fine in both salesforce classic and lightning experience but not in partner portal.  /a03/e?CF00N342300009cAB8={!Account.Name}&amp;CF00N342300009cAB8_lkid={!Account.Id}&amp;CF00N90000009cUVB={!Contact.Name}&amp;CF00N90000009cUVB_lkid={!Contact.Id}&amp;retURL={!Account.Id}   Any help on this. Speak Slower or Speak Slowlier? AFAIK the correct grammar for "speak slow" is "speak slowly" (slowly being an adverb). Please correct me if I am mistaken.  But in daily life I have not heard anyone saying "Speak slowlier".  I think I heard folks saying "Speak slower" but I also think it is incorrect.  Which is the best or correct form to convey the message?  Could that be the longish "Speak more slowly?" How does the pull down resistor work in this circuit? Find all natural numbers $x,y$ such that   $$3^x=2y^2+1$$  solutions are $(1,1)$, $(2,2)$, $(5,11)$. I found that parity of both is same and If $x$ Is odd it is of the form $4k+1$. Access server by host name? I have a mixed network with mostly Windows machines, a Mac, and a few Linux boxes.  There is no DNS or WINS server, and adding one is outside of my control.  If I put a clean install of 10.04 desktop on a computer, then all other machines on the network can get to that machine by hostname just fine.    However, if I put 10.04 server on the same computer, then the other machines can only get to it by IP address.  The hostname does not resolve.  What do I need to do on the server so that all the other machines on the network can get to it? While browsing on Safari and listening to iTunes I come across a video and then press the "play" button on the keyboard (to stop the music while I watch the video) it starts/stops the video instead of the music (I have no control over the music).  How can I quickly play/pause my music without affecting the video? How do you guys go about controlling column padding in tables?   Update  To clarify, I'm looking for a way to control both vertical and horizontal padding. So, if I had a simple table like in the following code snippet, I could pad the columns and make them look a bit less... ugly. :P   \begin{tabular}{|l|l|}     \hline     column 1 &amp; column 2 \\      \hline     I really would like this less &amp; crammed\\     \hline \end{tabular}   I tried this by using the command \vspace but it leaves gaps in the vertical lines. Java reflection: how to get field value from an object, not knowing its class Get steam to realize I have games already installed I uninstalled and re-installed steam. I didn't uninstall my games, and they still exist on my hard drive (I checked).  I have an SSD and a HDD, and to save space I install programs (including steam) to C:\Program Files (x86)\Steam drive (SSD) and games to D:\Games\SteamApps (HDD). How to I let steam know the programs are installed there? I am writing a few rather large pseudocode functions using algorithm and algorithmic, i.e. my code looks something like:  \begin{algorithm}                      \caption{Coolest Algorithm ever}           \label{findme}                           \begin{algorithmic} [1]                   % enter the algorithmic environment \REQUIRE    Here are a few variables \\             variable 2 \\             variable 3  \ENSURE     this is the output \\             output 2  \STATE $some cool code here$ \STATE $some cool code here$ \STATE $some cool code here$ \STATE $some cool code here$ \end{algorithmic} \end{algorithm}   Unfortunately this code does not fit on one page and I am definitely not able to split it into some subfunctions or so (I already did that as far as possible).  So now I need to split up the algorithm into two pages, but I have no idea how.  The easiest way I can imagine is just to start a new algorithm on the new page, but this time letting the line counter start at line 35 or so instead of 1. But how can I do that?  Please not that there is already a similar question here on this site, but it deals with the package algorithmicx. How can I make a camera the active one? I have multiple cameras in a scene. What I want to do is to change which one is active. This way I can view the scene from different angles. How would I do this? How to partition my hard drive for Ubuntu use? Till now I was windows user. From now on I want to use only Linux.   I have 500Gb HDD. How do I partition it properly? I read that there is no right or wrong way, but still, I am confused. I did something and I have primary partition mounted on / (160Gb) which I believe is a OS and 350Gb extended partition of which I have 4Gb of swap and 346Gb mounted on /home.  I got used to C:\ and D:\ partitioning, but I don't see file system in that way. I am lost. Where is what? How can I make C:\ partition for OS and D:\ for apps, movies, music, photos. Or what I want is Windows way and I have to get used to Linux way?