Oct 26, 2012 at 9:31pm Oct 26, 2012 at 9:31pm UTC
hi;
i wrote a code taking inputs from a file and then send these inputs to a float variable.
1 2 3 4 5 6
for (vector<float >::size_type j=0;j<3;j++)
{
myfile >> y;
temp(j) << y;
cout << temp(j);
}
but this gives the error: term does not evaluate to a function taking 1 arguments
Last edited on Oct 26, 2012 at 9:48pm Oct 26, 2012 at 9:48pm UTC
Oct 26, 2012 at 10:31pm Oct 26, 2012 at 10:31pm UTC
What exactly are you trying to do in line 4 and 5?
Oct 26, 2012 at 11:04pm Oct 26, 2012 at 11:04pm UTC
trying to send some float variables into a vector and then print the vector.
Oct 26, 2012 at 11:25pm Oct 26, 2012 at 11:25pm UTC
Is temp an array or vector? If so, try square brackets
1 2 3 4 5 6
for (vector<float >::size_type j=0;j<3;j++)
{
myfile >> y; // myfile is an ifstream and y a float?
temp[j] = y; // set vector element (temp is a vector of floats?)
cout << temp[j];
}
If not, what is it?
Last edited on Oct 26, 2012 at 11:57pm Oct 26, 2012 at 11:57pm UTC
Oct 27, 2012 at 9:49am Oct 27, 2012 at 9:49am UTC
thnak you this worked with () instead [].