Posts

Showing posts from October, 2008

Difference between class & struct?

There is only one difference betweeen a class & struct i.e., struct is by default public and class is private.

Method Chaining.

ob.fun1().fun2(): This way of calling functions is called Method Chaining. I have seen this using in big projects quite often. Here 1st ob.fun1() will be called which will return the some object. Then this object's fun2() will be called. The below example is to illustrate the Method Chaining. Eg: ================================================================= class A {     int x;     public:         A() {x=10; }         int getX() { return x;} }; class B {     int y;     public:         B() { y=20; }         A fun2(); }; A B::fun2() {     A o;     return o; } int main() {     A ob;     B ob2;     cout<<  ob2.fun2().getX() ;    return 0; } ================================================================= Output: 10