If an explicit copy constructor is defined that makes a complex copy, does:

int main()
{
            class shoe shoe1;
            class shoe shoe_copy(shoe1);
}

And

int main()
{
             class shoe shoe1;
             class shoe shoe_copy;
             shoe_copy=shoe1;
}

Basically I'm asking if the assignment operator accesses the complex copy constructor as an initialization of a class object to another class object would.

Well I dont think it would work out. Basically constructors should be members of that particular class or if you design it explicitly it will become a function with the same name of the class and will produce out an error.

If you wish to make the above methods work out . You will have to again call out the function from the constructors of your class for it to work.

only the first example invokes copy constructor. If the second one needs to work in the same manner as copy constructor does, you have to overload the assignment operator.

Thank you Sky Diploma, jencas, and kbshibukumar the site and your advice was very helpful. So basiclly what you were all saying was that the copy constructor and assignment operator are 2 different functions that must be defined by the coder seperately. I think that there is an automatic version of the overloaded assignment operator but it may be compiler dependant-I have one with Visual studio prfessional 2008.

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.