Can anyone help me to let me know whats happening in the below code when ,

data=cs.data;

happens
as FYI,
data is an empty list created of type std::list
and the constructor definition given below is a copy constructor

LDAPControlSet::LDAPControlSet(const LDAPControlSet& cs){
    DEBUG(LDAP_DEBUG_CONSTRUCT,"LDAPControlSet::LDAPControlSet(&)" << endl);
    data=cs.data;
}

thanks in advance

Copy constructor is invoke when you initialize an object with another.
In this case, it will be invoked something like this:

LDAPControlSet a;
//do something with 'a'.
LDAPControlSet b=a;//copy constructor invoked with 'a' as the argument
LDAPControlSet c;
c=b;// copy constructor *not* invoked but initialization operator invoked
LDAPControlSet d(a);//explicit invocation of the copy constructor with 'a'  as argument

When this copy constructor is called, it simply copies the content of the std::list cs::data to its own std::list data.
In the above example, a is passed as parameter to the copy constructor's parameter cs.
cs.data is the std::list of that argument
and data is the std::list of the own object.

THanks Siddhant.

one more help,
actly i m trying to reproduce the segmentation fault in my code, please let me know whether the below code is capable of giving rise to that error or not or if not what should i do to this code.

int main()
{
        LDAPControlSet *cset = new LDAPControlSet();
        LDAPControlSet *cs = new LDAPControlSet("1");

        delete cs;
        data=cset.data;

        data=cs.data;

        cout<<"I am here";
        return 0;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.