Friday 20 January 2012

Make your vi editor work properly in ubuntu

Hello Friends,

if you are using ubuntu and you have problem of vi editor not working properly then don't worry .
I have a solution . You just have to install a package and that's all !!





1)first connect to internet

2)open your terminal then write the following command
$ sudo apt-get install vim


3)download the package ...
this is working for me.. Hoping it will work for you also.

Thursday 12 January 2012

Object Slicing



  • In object-oriented programming, a subclass typically extends its super class by defining additional member variables.

  •  If a super class instance is assigned its value from a subclass instance, member variables defined in the subclass cannot be copied, since the super class has no place to store them. This is a natural and unavoidable consequence of assignment by value from subclass objects.

  •  The term object slicing is sometimes used to refer to this aspect of assignment by value to a super class instance.

  • Object slicing is also used to refer to a more subtle, problematic, case in which an object assignment by value appears to be to a superclass instance but is actually to a subclass instance.

  •  From the perspective of object memory layout, the member variables of the source instance can be thought of as having been "sliced off", leaving the corresponding member variables in the destination instance unchanged.

  •  It is this partial assignment (arguably a more apt term) that often surprises programmers and leads to unintended consequences.

  • Unexpected object slicing can happen in languages such as C++ in which assignment by value is not polymorphic.

  •  It is not possible in Java, which allows object assignment only by reference, or the D programming language, which allows object inheritance only through reference types.

Example:

struct A
{
    A(int a) : a_var(a) {}
    int a_var;
};

struct B : public A
{
    B(int a, int b) : A(a), b_var(b) {}
    int b_var;
};

B &getB()
{
    static B b(1, 2);
    return b;
}

void example()
{
    // Normal assignment by value to a
    A a(3);
    a = getB();
    // a.a_var == 1, b.b_var not copied to a

    B b2(3, 4);
    A &a2 = b2;
    // Partial assignment by value through reference to b2
    a2 = getB();
    // b2.a_var == 1, b2.b_var == 4!
}