Hi,
    to say very simply like .. if there is any class like student which had 
single parameterised constructor like student(int i).  Then ,we mention 
anything like Student x=10; 
  Consider the following example:
  class student
  {
  int num;
  public:
  student()
  {// some implementation
  }
  student(int i)
  {
  num=i;
  //some implementation
  }
  student operator = (student &obj)
  {
  }
  };
  main()
  {
  student x;
  student st1=10; // here a tem object will be created with 10 as parameter and 
calls parameterised constructor. Then default copy constructor will be called 
to copy the temp object to our desired object.(I tried by giving a deep copy 
constructor , i eman I provided a copy constructor . But hetting an error 
because , it is trying to type caset 10 into the class reference.) Then that 
temp object will be deleted. 
    If we provide explicit key word at constructor , then this issue won't be 
there and we will get error at styudent s1=10; line.
   
   
  Thanks&Regards,
  Gopi.k
  9884609596.
  

Ray Devore <[EMAIL PROTECTED]> wrote:
          --- Baktavatsala reddy <[EMAIL PROTECTED]>
wrote:
> The Implicit call calls the copy constuctor
> directly. Whereas the explicit call first call the
> copy constructor, creates the object and then again
> calls the assignment operator to assign this newly
> created to an another object.

Not quite, see below.

Ray

> 
> Knowledge Seeker <[EMAIL PROTECTED]>
> wrote: Manish wrote:
> > Dear Experts
> >
> > What is the advantage in an explicit call. Both
> look the same to me.
> >
> > Samp obj(10,12); // Implicit call
Calls constructor (not copy constructor) to create and
initialize obj

> > Samp obj = Samp(12,22) // Explicit Call 
Calls constructor (not copy constructor) for
Samp(12,22) and creates a temp object, then calls copy
constructor to create and initialize obj with the temp
object, then calls the destructor to delete the temp
object so you get two additional function calls with
the second method.

> >
> > Both compile fine in Borland Turbo C 3.0.
> 
> I dare you use a new compiler ;)
> 
> > Is it matter of style? 
> > Generally which of the two is preferred?
> >
> > Thanks a lot
> >
> > manish
> >
> >
> > 

__________________________________________________________Get the free Yahoo! 
toolbar and rest assured with the added security of spyware protection.
http://new.toolbar.yahoo.com/toolbar/features/norton/index.php


         


      
  GopiKrishna Komanduri
Software engineer
Covansys,
  Chennai,
  9884965748.
  [EMAIL PROTECTED]

   




       
---------------------------------
Be a better Heartthrob. Get better relationship answers from someone who knows.
Yahoo! Answers - Check it out. 

[Non-text portions of this message have been removed]

Reply via email to