Area is a class with a constructor that takes a double as a parameter. However the code above doesn't work and I get an error "Redefinition of 'data' with a different type: 'Area' vs 'double'. When i simply replace Area(data) with Area(5), the code will run. It seems as if it wouldn't take my variable as a parameter.
Is "Area" a class? or a object? Becuase if its a class, thats not how you call the constructor. Please show us more code. oh, and put the code between code tags - http://www.cplusplus.com/articles/jEywvCM9/
This is called Most vexing parse: If something can be reinterpreted as declaration, it will be. As parentheses usually can be dropped, line 4 is interpreted as Area data;, which is variable declaration.
Even if would not work like that, this line is still meaningless: it creates unnamed temporary which is instantly destroyed.
Maybe you wanted something like Area some_area(data);