Type conversion

May 2, 2013 at 6:26pm
Well, I just wanted to assign one object to another(both of different classes)
supposing
Destination Object=Source Object;
and I define a constructor in the destination object...(I am overloading the constructor to make more than one assignment)

Now, the error is after the call to constructor is made... a destructor is also called...

So anyone has any idea how i could clear this error??or suggest me an alternative for type conversion
May 2, 2013 at 6:29pm
Please post your code.
May 2, 2013 at 6:45pm
hey,fransje this is a very small part of the program coz the whole program is too big...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
class HostelAllotment
{
public:
	int noboys;
	int nogirls;
};
class  Boys:public HostelAllotment
{
       public:
             ~Girls(){cout<<"Detroying b";}
              int x[6];
	int bfees;
};
class Girls:public HostelAllotment
{
      public:
             ~Girls(){cout<<"Detroying g";}
             int x[6];
             int gfees;
};

class admin:public Boys,public Girls
{
      public:
      admin(Boys a)
      {
            this->Boys::bfees=a.bfees;
                       for(int i=0;i<5;i++)
            {
                    Boys::x[i]=a.x[i];
           
            }
};
May 3, 2013 at 3:01am
Could someone help me here??
May 3, 2013 at 6:15am
the error is after the call to constructor is made

so could you post the part where that constructor is called from and the lines after that call (your main function?) too?
May 3, 2013 at 7:23am
Now, the error is after the call to constructor is made... a destructor is also called...

This is happened bcoz your not used reference Boys variable in admin constructor use it as below.

admin(Boys &a)
Topic archived. No new replies allowed.