I was looking at this:

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
		int A,B,C;
		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);
	return 0;

(This gives me "unexpected ',', ';', or '.'" on the Test T instantiation)

Any thoughts?


>>Test T(1).setB(4);

Should be

Test T(1);

So it's really not that beneficial, you can just write:


instead of

T.setB(4); T.setC(5);



The second method you posted is preferred. The above method is unconventional and may be easily misunderstood and confused by readers.