I have a problem with compiling and linking the main.cxx and Vec.cxx files, which are shown below.  To compile, I am using g++ with the following command:g++ -std=c++11 -c main.cxx Vec.cxx. To link, simply g++ main.o Vec.o. But doing this I get undefined reference errors to the create and uncreate functions, which are used by the constructors and the destructor.  Vec.cxx:  // Vec.cxx // Source file for Vec template class header.  #include "Vec.h"  #include &lt;memory&gt;  template &lt;class T&gt; Vec&lt;T&gt;&amp; Vec&lt;T&gt;::operator=(const Vec&amp; rhs){    if(&amp;rhs != this){      // free array in the left hand side     uncreate();      create(rhs.begin(),rhs.end());    }    return *this; }  template &lt;class T&gt; void Vec&lt;T&gt;::create(){   data = avail = limit = 0;    return; }   template &lt;class T&gt; void Vec&lt;T&gt;::create(size_type n, const T&amp; val){   data = alloc.allocate(n);   limit = avail = data + n;   std::uninitialized_fill(data,limit,val);    return; }   template &lt;class T&gt; void Vec&lt;T&gt;::create(const_iterator b,const_iterator e){   data = alloc.allocate(e-b);   limit = avail = std::uninitialized_copy(b,e,data);    return; }   template &lt;class T&gt; void Vec&lt;T&gt;::uncreate(){   if (data) {     // Destroy (in reverse order) the constructed elements;     iterator it = avail;     while(it != data){       alloc.destroy(--it);     }      // Return all the space that was allocated     alloc.deallocate(data, limit-data);   }    data = limit = avail = 0;    return; }   template &lt;class T&gt; void Vec&lt;T&gt;::grow(){   size_type new_size = std::max(2* (limit-data), std::ptrdiff_t(1));    iterator new_data = alloc.allocate(new_size);   iterator new_avail = uninitialized_copy(data,avail,new_data);    uncreate();    data = new_data;   avail = new_avail;   limit = data + new_size;    return; }   template &lt;class T&gt; void Vec&lt;T&gt;::unchecked_append(const T&amp; val){   alloc.construct(avail++,val);    return; }   Vec.h:  #ifndef VEC_H #define VEC_H  #include &lt;memory&gt;  template&lt;class T&gt; class Vec{   public:   // define names    using iterator = T*;   using const_iterator = const T*;   using size_type = size_t;   using value_type = T;    // Size and index operators   size_type size() const { return avail - data; }   T&amp; operator[] (size_type i) { return data[i]; }   const T&amp; operator[] (size_type i) const { return data[i]; }     // Constructors   Vec() { create(); }   explicit Vec(size_type n, const T&amp; val = T()) { create(n, val); }   Vec(const Vec&amp; v) { create(v.begin(),v.end()); }    // Destructor   ~Vec() { uncreate(); }    // Assignment operator   Vec&amp; operator=(const Vec&amp;);    // push_back function   void push_back(const T&amp; val){     if(avail == limit){       grow();     }      unchecked_append(val);     return;   }    // Iterators   iterator begin() { return data; }   const_iterator cbegin() const { return data; }   const_iterator begin() const { return data; }    iterator end() { return limit; }   const_iterator end() const { return limit; }   const_iterator cend() const { return limit; }   private:   iterator data;    // First element in Vec   iterator avail;   // One past the last allocated memory element   iterator limit;   // One past the last element in Vec    std::allocator&lt;T&gt; alloc;    void create();   void create(size_type, const T&amp;);   void create(const_iterator,const_iterator);    void uncreate();    void grow();   void unchecked_append(const T&amp;); };   #endif   main.cxx:  #include "Vec.h"  int main(int argc, char **argv){    Vec&lt;int&gt; v(10,2);     return 0; }   Edit: Thankyou for marking as duplicate, the link resolved my question. I moved the functions into the header file and everything works now.
Quote from :     The only portable way of using templates at the moment is to implement them in header files by using inline functions.   Why is this?  (Clarification: header files are not the only portable solution. But they are the most convenient portable solution.)
Why is the Star Trek 2009 reboot called a reboot? Doctor Who (2005) isn't called a reboot. It is called a continuation of the old series. This was made possible by that regeneration ju-ju and stuff.  On the other hand, Star Trek 2009 reincarnation is often called a reboot. Nobody dared call it continuation. I don't think I need to do citation because it's common.  Now, if we actually go into the details:   The new universe contains two Spock. One is from the original timeline. The Spock Prime even gives data from the original timeline like trans-warp equation, Khan etc. We see other past data from before the timeline diverged. For example, Scott told that he transwarped Admiral Archer's dog. "Archer's dog" existed in Star Trek: Enterprise TV series.   So, why didn't the legacy survive in-universe? Why isn't it considered a continuation of the old Star Trek TV shows and movies?  Or, is the reboot word used by mistaken fans and media only?  Update: After the release of Star Trek: Beyond (2016), this is no longer a confusion as the movie showed a photo from original timeline. I am superimposing CGI over video footage, and have run into a problem in making materials for objects that act as 'shadow catchers'.  Essentially I want a shader that is shadeless—like an emitter—but catches shadows and light from other objects. This is so I can reconstruct objects in footage so other objects in the scene interact convincingly with them.  Here's an overcomplicated diagram to illustrate my point:   (In this particular scenario, the problem could be glossed over by using RGB curves, but that is definitely not the case with more complicated scenes)  Isn't this a common situation? How to the real guys do it? Thank you.  (I am welcome suggestions of other ways of doing this.) Booking travel tickets for visa without paying? Bad substitution: no closing "`" in a heredoc / EOF I'd like to print a man style usage message to describe a shell function like this output man find:  NAME        find - search for files in a directory hierarchy  SYNOPSIS        find [-H] [-L] [-P] [-D debugopts] [-Olevel] [starting-point...] [expression]  DESCRIPTION        This  manual  page  documents the GNU version of find.  GNU find searches the directory tree rooted at each        given starting-point by evaluating the given expression from left to  right,  according  to  the  rules  of        precedence  (see section OPERATORS), until the outcome is known (the left hand side is false for and opera‐        tions, true for or), at which point find moves on to the next file name.  If no  starting-point  is  speci‐        fied, `.' is assumed.  OPTIONS   I am facing an error message on the ` character. Following simple script shows the error:  ~$ cat &lt;&lt;EOF `.' EOF  bash: bad substitution: no closing "`" in `.'   I though heredoc was a cool way to echo strings by pasting them without having to escape its content such a quotes, etc... I assume I was wrong :/  Can someone explain this behavior please? Can heredoc accept ` character?  Edit 2: I accepted the answer of quoted here-document  &lt;&lt;'END_HELP', but I finally won't use it for this kind of complete manual output as  does   Edit 1: (For future reads) the limit with using quoted here-document is that is prevents to use tput in the here-document. To do so, I did the following:   unquoted here-document, for tput commands to be executed prevent the "bad substitution" error by escaping the backtick instead use tput within the  here-document   Example:  normal=$( tput sgr0 ) ; bold=$(tput bold) ;  cat &lt;&lt;END_HELP # here-document not quoted ${bold}NAME${normal}        find - search for files in a directory hierarchy  ${bold}SYNOPSIS${normal}        find [-H] [-L] [-P] [-D debugopts] [-Olevel] [starting-point...] [expression]  ${bold}DESCRIPTION${normal}        This  manual  page  documents the GNU version of find.  GNU find searches the directory tree rooted at each        given starting-point by evaluating the given expression from left to  right,  according  to  the  rules  of        precedence  (see section OPERATORS), until the outcome is known (the left hand side is false for and opera‐        tions, true for or), at which point find moves on to the next file name.  If no  starting-point  is  speci‐        fied, \`.' is assumed. END_HELP  unset normal ; unset bold ;   Here, note the escaped backtick that was source of error:  \`.' Limit of function of hyperbolic How to show that every Boolean ring is commutative? Why doesn't the last digit method work for divisibility by 4? I wish to explain to a grade 5 kid, the answer to the question - 'When can we know that the observing the last digit of a number will not be sufficient to determine its divisibility by a given N?'  For example - It doesn't work for 3, because we get all sorts of digits, i.e. from 0 to 9, at the units place. The same reason works for 7 and 9.   But what would be a convincing argument for 4 and 8? Even though the last digits form a pattern - 0, 2, 4, 6 and 8 - but we're still not sure about its divisibility. Availability of MXD file for OpenStreetMap data in Esri Geodatabase? From what I understand, an ArcGIS mxd file contains the "styling" information on how to show data.  I downloaded and imported OpenStreetMap data into my geodatabase. Now I need to show them.  Is there any available mxd file match the OpenStreetMap fields/values that I can use?  I check this question(), but the links are all dead.  ps: right now the all the highway/roads/trail display as a single line in my map. I want to use mxd to show them in a better way, like Mapnik or google. This winter I am planning to track my downhill skiing/snowboarding using a GPS.  Most of my riding will occur at the same resort.  I would like to be able to create a sort of "heatmap" that shows the amount of runs that I have made in a given area.  As I add more and more GPS traces to my database, my goal would be to see a sort of linear heatmap of the most traveled areas.  Given the nature of downhill skiing, you would expect the uphill chairlift lines will be the "hottest" because it will be the only places visited over-and-over again.  Given that 1) my track will not be the same every time and 2) the area covered by following one "run" may be a few hundred feet wide, what might be the best way to analyze this "linear" data to create a sort of heatmap?  My thoughts were to buffer the lines, then intersect the polys to get a sort of Venn Diagram thing going.  My preference is to use open-source technologies.  I've got QGIS and PostGIS loaded and available.  UPDATE: In regards to @blah238's response, I was thinking of something that might be able to "collect" the number of passes ("runs") through an area, and then symbolize by the count.  Conceptually, this would be similar to ArcGIS "" (but for lines, not points) or  (but for multiple line in roughly the same area).  A more visual example of a similar concept might be a traffic-flow map, where highly-congested areas would equate to "highly-traveled" ski runs/areas:    I've read the following questions that may give some ideas, but they don't really address what I am trying to accomplish: Evaluate $\mathop {\lim }\limits_{x \to 0} \left( {{1 \over {{{\sin }^2}x}} - {1 \over {{x^2}}}} \right)$ I tried l'Hospital but that will require a lot (and I mean A LOT!!!) of differentiating  Is there a shortcut? $$\mathop {\lim }\limits_{x \to 0} \left( {{1 \over {{{\sin }^2}x}} - {1 \over {{x^2}}}} \right)$$  Thanks in advance I want to install the latest version of Eclipse but the Ubuntu Software Centre contains an older version.  Is there a PPA or some other way to install latest Eclipse? Please describe the steps for full installation. Are there any differences between insmod and modprobe? What would be the Slater's determinant representation for an excited state? Setup  Introducing this spinorbital notation:  \begin{align} \Psi_1=\chi_{(r1)}\alpha_{(\omega1)}  = 1 \\ \Psi_1=\chi_{(r1)}\beta_{(\omega1)}  = \bar{1} \end{align}  and the Slater's determinant, for a system of two electrons, is:  \begin{align} |\Psi\rangle = \frac{1}{\sqrt{2}} \Big|  \begin{array}{cc} 1 &amp; \bar{1}  \\ 2 &amp; \bar{2}  \\ \end{array}  \Big| = \frac{|1\bar{2}\rangle-|\bar{1}2\rangle}{\sqrt2} \end{align}  Question  Based on the example, what would be the Slater's determinant representation for an excited state like $\Psi_a^r$ (i.e. with parallel spins like: $|\bar{1}\bar{2}\rangle$) and $\Psi_{ab}^{rs}$ (feel free to use any number) ? NetworkOnMainThreadException Do the following negations mean the same thing? I don't think you understood me. / I think you misunderstood me.    Do these senteces mean the same thing? If not, what's the difference?  Edit: I just realized that I asked something different from what I originally wanted. So I am also interested in the following comparison:     I don't think you understand me. / I think you don't understand me. Consider the diagram below:  (Author: Joshua Hykes )  From this diagram we can see that the absorption coefficient for the photoelectric effect generically decreases with the increase in energy of the photon. What is the physical reason for this decrease. (i.e. why does the probability of photoelectric absorption decreases with increasing photon energy).  Note: I am aware that the large spin is due to more inner electrons been able to be lifted.  Edit For Clarity  I will here rephrase the question: in the above diagram there is a general decrease in the absorption coefficient due to the photoelectric effect (i.e. the absorption of a photon by an electron and subsequent emission of that electron) with energy (ignoring the occasional absorption edge). This is of course linked to a decrease in the probability of the photoelectric effect occurring (and a corresponding decrease in the cross section). My question is: what is causing this decrease with increasing energy. (For the purpose of this question I am ignoring the contribution due to the Compton effect and pair production and simply focusing on the cross section due to the photoelectric effect.) I've created main SELECT statement like below. For every row in Base table (base on IDKey I've added columns with values from result of INNER JOIN of few tables.  SELECT   IDKey,    Name,    (select Amount from Table1 INNER JOIN Table2 ... where ID=IDKey) AS AmountTypeX,    (select Amount from Table1 INNER JOIN Table2 ... where ID=IDKey) AS AmountTypeY FROM BaseTable   BaseTable:  IDKey Name  ---------- 1     Ian 2     John 3     Ann ...   INNER JOIN of few tables Table1, Table2... :   ID Amount Type -------------- 1  100    X 1  200    Y 2  300    X 2  400    Y 3  500    X 3  600    Y ...   Result looks like:  IDKey  Name  AmountTypeX  AmountTypeY ------------------------------------- 1      Ian   100          200 2      John  300          400 3      Ann   500          600 ...   Do you have any suggestion how to avoid this nested SELECT statements in the main query at the begining and made this query simpler and more effective ?  I wast thinking about PIVOTING of the INNER JOIN result to look like below (all data for particular ID in one row) and then JOIN with main query but Have no idea how to do this and is it possible.  ID  X   Y ----------- 1   100 200 2   300 400 3   500 600 ... Showing that $\frac{\sqrt[n]{n!}}{n}$ $\rightarrow \frac{1}{e}$ Show:$$\lim_{n\to\infty}\frac{\sqrt[n]{n!}}{n}= \frac{1}{e}$$  So I can expand the numerator by geometric mean. Letting $C_{n}=\left(\ln(a_{1})+...+\ln(a_{n})\right)/n$. Let the numerator be called $a_{n}$ and the denominator be $b_{n}$ Is there a way to use this statement so that I could force the original sequence into the form of $1/\left(1+\frac{1}{n}\right)^n$ How do I figure the dice and bonuses for attack rolls and damage rolls? I'm building my character, a Half-Elf Ranger, and I'm a little confused about how to work out the attack bonus and the damage bonus.  So, please tell me if I've got this right:   I'm proficient with a longbow. That means my attack roll is 1d20 + prof bonus + Dex modifier. The damage roll however is 1d8 + Dex modifier.   I'm just a little confused about working out the numbers (without even going into spells and when to roll for attack, etc.) Why is human vision restricted to 400-700 nm? Across the electromagnetic spectrum, 400-700 nm is a narrow spectrum of frequencies and focused in the region of short wavelengths. For example, radio waves cover a large range of frequencies unexploited by the visual system. So what biological reason is there that evolved us to use such a small frequency bandwidth for vision?