I was looking at this:
http://www.parashift.com/c++-faq-lite/ctors.html#faq-10.18
I don't understand
File f = OpenFile("foo.txt");
It seems like File is one class, and OpenFile is a separate class, so how can you assign an OpenFile to a File?
Also, is it necessary to have this second class? Why not something like this:
#include <iostream>
class Test
{
private:
int A,B,C;
public:
Test& setB(const int b)
{
B = b;
return *this;
}
Test& setC(const int c)
{
C = c;
return *this;
}
Test(const int a) : A(a)
{
B = 0;
C = 0;
}
void Output()
{
std::cout << A << " " << B << " " << C << std::endl;
}
};
int main(int argc, char *argv[])
{
Test T(1).setB(4);
T.Output();
return 0;
}
(This gives me "unexpected ',', ';', or '.'" on the Test T instantiation)
Any thoughts?
Dave