Why do std::istringstream only work here with a constructor? The code below compiles and works as expected. On line 11, when I change std::istringstream iss(temp) to std::istringstream iss() , it stops working. An error occurs on line 18, iss.str(temp): expression must have class type but it has type &quot;std::istringstream (*)()&quot; Why would a change to the constructor make a difference? I checked the , it shouldn't make a difference, but I must be missing something. Any thoughts? #include &lt;vector&gt; #include &lt;iostream&gt; #include &lt;string&gt; #include &lt;sstream&gt;  int main() {      int n, m;     std::string temp;     std::vector&lt;int&gt; ranked, player;     std::istringstream iss();      // Get the Input      std::getline(std::cin, temp);     n = std::stoi(temp);     std::getline(std::cin, temp);     iss.str(temp);     while(!iss.eof()) {         std::getline(iss, temp, ' ');         ranked.push_back(std::stoi(temp));     }      return 0; }
Default constructor with empty brackets Is there any good reason that an empty set of round brackets (parentheses) isn't valid for calling the default constructor in C++?  MyObject  object;  // ok - default ctor MyObject  object(blah); // ok  MyObject  object();  // error   I seem to type "()" automatically everytime. Is there a good reason this isn't allowed?
Proof that the nth root of a rational s/t is irrational unless s and t are perfect nth powers I'm trying to prove that $\sqrt[n]{\frac{s}{t}}$ is irrational unless both s and t are perfect nth powers. I have found plenty of proofs for nth root of an integer but cannot find anything for rationals. Also trying to work up from the proofs I have found is rather difficult.  My lecturer wants me to prove this using uniqueness of prime factorisation but I also have no idea where to start with that.   Any help is greatly appreciated. ext4 partition size / free space discrepancies While creating a 250GiB backup partition for my data, I have noticed lots of discrepancies between reported partition size and free space in Nautilus, gParted, df, tune2fs, etc.  At first I thought it was a GiB / GB confusion. It was not.  Then I thought it could be ext4's reserved blocks. It was not.  Im completely puzzled. Here are some images. Here are the steps:   First, NTFS. 524288000 sectors x 512 bytes/sector = 268435456000 bytes = 268.4 GB = 250 GiB.      Nautilus say "Total Capacity: 250.0 GB" (even though its actually GiB, not GB). Apart from that minor mislabeling, so far, so good   Now, same partition, formated as ext4 with gparted:     First, Last and Total sectors are the same. It IS the same 250GiB partition. Used size is 4.11GiB (reserved blocks maybe?)    Nope. Looks like reserved blocks are 12.7 GiB (~5%. ouch!). But... why Total Capacity is now only 246.1 GiB ???. That difference (sort of) matches the 4.11 GiB reported by gparted. But... if its not from reserved blocks, what is it? And why gparted didnt report that 12.7GiB of used space?  $ df -h /dev/sda5 Filesystem            Size  Used Avail Use% Mounted on /dev/sda5             247G  188M  234G   1% /media/BACKUP   df matches Nautilus in reported free space. But.. only 188M used? Shouldnt it be ~12GB? And total capacity is still wrong. So i ran tune2fs to find some clues. (irrelevant output is ommited)  $ sudo tune2fs -l /dev/sda5 tune2fs 1.41.12 (17-May-2010) Filesystem volume name:   BACKUP Filesystem UUID:          613d592e-47f5-4206-96a7-210090d340ef Filesystem features:      has_journal ext_attr resize_inode dir_index filetype extent flex_bg sparse_super large_file huge_file uninit_bg dir_nlink extra_isize Filesystem flags:         signed_directory_hash  Filesystem state:         clean Filesystem OS type:       Linux Block count:              65536000 Reserved block count:     3276800 Free blocks:              64459851 First block:              0 Block size:               4096   65536000 total blocks * 4096 bytes/block = 268435456000 bytes = 268.4 GB = 250 GiB. It matches gparted.  3276800 reserved blocks = 13421772800 bytes = 13.4 GB = 12.5 GiB. It (again, sort of) matches Nautilus.  64459851 free blocks = 264027549696 bytes = 264.0 GB = 245.9 GiB. Why? Shouldnt it be either 250-12.5 = 237.5 (or 250-(12.5+4.11)=~233) ?  Removing reserved blocks:  $ sudo tune2fs -m 0 /dev/sda5 tune2fs 1.41.12 (17-May-2010) Setting reserved blocks percentage to 0% (0 blocks)  $ sudo tune2fs -l /dev/sda5 tune2fs 1.41.12 (17-May-2010) Filesystem volume name:   BACKUP Filesystem UUID:          613d592e-47f5-4206-96a7-210090d340ef Filesystem features:      has_journal ext_attr resize_inode dir_index filetype extent flex_bg sparse_super large_file huge_file uninit_bg dir_nlink extra_isize Filesystem flags:         signed_directory_hash  Filesystem state:         clean Filesystem OS type:       Linux Block count:              65536000 Reserved block count:     0 Free blocks:              64459851 Block size:               4096   As expected, same block count, 0 reserved blocks, but... same free blocks? Didnt I just freed 12.5 GiB ?  $ df -h /dev/sda5 Filesystem            Size  Used Avail Use% Mounted on /dev/sda5             247G  188M  246G   1% /media/BACKUP     Looks like I did. Avaliable space went up from 233 to 245.9 GiB. gparted didnt care at all, showing exactly same info! (useless to post an identical screenshot)  What a huge mess!  I tried to document it as best as I could... So, please can someone give me any clue on what's going on here?   What are those misterious 4.11 GiB missing from NTFS -> ext4 formatting? Why there are so many discrepancies between gparted, Nautilus, tune2fs, df? What is wrong with my math? (questions in bold scattered this post)   Any help is appreciated. While I can not figure what is going on, I am serilously considering giving up on ext4 in favor of NTFS for everything but my / partition.  Thanks! A group $G$ with a subgroup $H$ of index $n$ has a normal subgroup $K\subset H$ whose index in $G$ divides $n!$ Structure of a C++ Object in Memory Vs a Struct If I have a class as follows     class Example_Class     {        private:          int x;           int y;         public:           Example_Class()           {               x = 8;              y = 9;          }        ~Example_Class()         { }     };   And a struct as follows  struct {    int x;    int y; } example_struct;   Is the structure in memory of the  example_struct simmilar to that in Example_Class  for example if I do the following  struct example_struct foo_struct; Example_Class foo_class = Example_Class();  memcpy(&amp;foo_struct, &amp;foo_class, sizeof(foo_struct));   will foo_struct.x = 8 and foo_struct.y = 9 (ie: the same values as the x,y values in the foo_class) ?  The reason I ask is I have a C++ library (don't want to change it) that is sharing an object with C code and I want to use a struct to represent the object coming from the C++ library. I'm only interested in the attributes of the object.  I know the ideal situation would be to have Example_class wrap arround a common structure between the C and C++ code but it is not going to be easy to change the C++ library in use. Understanding central limit theorem What is wrong with the following sentence:      The Central Limit Theorem  implies that, as the sample size grows, the error distribution approaches normality.   Am I correct by saying that it should in stead state the MEAN of the sample error approaches zero as sample size grows? Should I use #define, enum or const? I was surprised to discover my dictionary had this entry for dilemma:     a situation in which a difficult choice has to be made between two or more alternatives, esp. equally undesirable ones   The notion of dilemma meaning two or more flies against what I was taught about the word. The very idea of a  is specifically based on the number two.  Has my dictionary merely updated its definition to encapsulate the many people who use dilemma for more than two equal choices? Or was someone in my youth being unnecessarily pedantic? How does Meta Stack Exchange work? Meta Stack Exchange seems to have different rules and user behavior than the "regular" Stack Exchange sites.  How is it different?    Individual questions answered below:                Related Circles importing as crossed boxes into Adobe Illustrator Why are these pistons pushing? I've lately become hooked into building computers in Minecraft and today I decided to build a giant hard drive. I've built HDDs before, but not at the scale I'm currently attempting, and I anticipated problems. As I was wiring some pistons, they activated and pushed forward oddly. As far as I can tell, there's nothing powering them.    I thought at first that it might be the redstone torches (top left of above pic) but they aren't powered.   Here's a top view of the same pistons. I also thought the line of redstone above  them might be the problem (middle of above pic), but when I destroy it, the pistons stay extended.  Is there a reason why my pistons are extending? If so, is there a way to get them to power (when I want them to) without disturbing the pistons above? Why is it not true that if $\Phi \models \exists x \phi$ then there is a term $t$ with $\Phi \models \phi \frac{t}{x}$? Can a spell be prepared once and cast multiple times? Unintentional mouse movements, am I paranoid? How do you use plural or singular form of an adjective? Why can't the indefinite integral $\int\frac{\sin(x)}{x}\mathrm dx$ be found? I came across a list of functions in my calculus textbook whose indefinite integral cannot be found. It was written that the integral $$\int \frac{\sin(x)}{x} dx$$ cannot be evaluated without any explanation as to why.  I did some research over the internet and found out that the definite integral $$\int_{0}^{\infty} \frac{\sin(x)}{x} dx$$ can be evaluated using Laplace transformation and is equal to $\pi /2$. But I still couldn't find answer to my original question. I read somewhere that the integral cannot be expressed using 'elementary functions'. A little help is appreciated, I'm in Calc 1 going advanced than my course but I am sorry if my post shows lack of research. Thank you! How to perform a true GIS clip of polygons layer using a polygon layer in R? I would like to do a true GIS Clip in R of soils polygons using a series of single boundary polygons, but I cannot find an R function to properly do it. It should work just like the clip function in ESRI's ArcMap. I've tried the over method in sp package but it doesn't seem to work for polys over polys.   One suggestion was to use the gIntersection in rgeos package as a clip using the following code:  #------------------------------------ library(rgeos) library(maptools)  #Read layers as SpatialPolygonsDataFrame (both the same Albers projection) Soils_poly = readShapePoly("Soils_polygons")  #Note - Has 400 polygons clipper_poly = readShapePoly("clipper_polygon")  #Note - Has 1 polygon  #Try gintersection as clip  Clipped_polys = gIntersection(Clipper_Tile_poly, Soils_poly)  #-----------------------------------   This takes 5 minutes to run (way too slow) and errors with this:     Error in RGEOSBinTopoFunc(spgeom1, spgeom2, byid, id, drop_not_poly, "rgeos_intersection") :      TopologyException: no outgoing dirEdge found at -721459.77681285271 2009506.5980877089   I also tried this code to check for overlap:  gIntersects(Clipper_Tile_poly, Soils_poly)   and the result was TRUE. clip function in ESRI ArcMap works fine for this data.   Anyone knows of an R function to properly do a clip on spatial polygons using spatial polygons? Is the Ratio of Associative Binary Operations to All Binary Operations on a Set of $n$ Elements Generally Small? I started thinking about the number of associative (binary) operations on a set with $n$ elements today.  Looking online I found  which indicates only $113$ of the possible $19,683$ operations on a three-element set satisfy association.  So, $50\%$ of binary operations on a two-element set satisfy association, and less than $0.6\%$ of all binary operations on a three element set satisfy association.  For an $n$-element set, where $n$ denotes a natural number, is the ratio $R_{n}=A_{n}/B_{n}$, of the number of associative binary operations $A_{n}$ to the number of all binary operations $B_{n}$, in general small?  I don't mean the following questions as equivalent, but since they seem more concretely answerable in principle, does   $$ \lim_{n \to +\infty} \frac{A_{n}}{B_{n}} = 0 ? $$       Also, is $F : n \to R_{n}$ a monotonically decreasing function?  Some Background of the Question: In his Linear Algebra Problem Book 1995 on p. 6 Paul Halmos writes "The commonly accepted attitudes toward the commutative law and the associative law are different.  Many real life operations fail to commute; the mathematical community has learned to live with that fact and even to enjoy it.  Violations of the associative law, on the other hand, are usually considered by specialists only."  For all I know, Halmos might only have written that to motivate the study of Linear Algebra and doesn't quite literally mean what he appears to say.  But, if he means what he appears to say, and if $F : n \to R_{n}$ is monotonically decreasing, or $R_{n}$ is generally small, I think there's something amiss with what Halmos says, since non-associative operations seem so common that one may as well enjoy them. Is it possible to sort non-stackable items in minecraft? are super sweet.  But, I have a skeleton farm, and am getting tons of non-stackable drops.  Since armor can be smelted into iron/gold, I'd like to smelt those drops in a furnace, and burn bows in a furnace.  And trash all leather armor.  Is there a way to sort out these non-stackable items in vanilla survival? How do I redirect command output to a file? Under what assumptions can a semigroup $(S,*)$ be embedded into a group?