what is differnce between both following
-
I have one doubt please give me the answer. I read some where in C++, if we want to access base class constructor using derived class constructor like bellow is possible:
class base
{
base()
};class derived:public base
{
derived():base()
{
}
};normally i used like bellow
class base
{
base()
{
}
};class derived:public base
{
derived()
{
}
};My question is what is the difference between both approaches. In which cases I have to use first one and in which cases i have to use second one.
To invent something, you need a mountain of junk in your mind. ---------------------Thomas alva edison
-
I have one doubt please give me the answer. I read some where in C++, if we want to access base class constructor using derived class constructor like bellow is possible:
class base
{
base()
};class derived:public base
{
derived():base()
{
}
};normally i used like bellow
class base
{
base()
{
}
};class derived:public base
{
derived()
{
}
};My question is what is the difference between both approaches. In which cases I have to use first one and in which cases i have to use second one.
To invent something, you need a mountain of junk in your mind. ---------------------Thomas alva edison
I have a doubt about people who post the same question 3 minutes after they have asked it the first tiome !!! STOP IT BE PATIENT 'g'
-
I have a doubt about people who post the same question 3 minutes after they have asked it the first tiome !!! STOP IT BE PATIENT 'g'
sorry, And thanks for valuable reply. My internet connection is having problem. First time it given a message "not update your message". That's why i updated again. Any way sorry for inconvenience. I deleted first one.
To invent something, you need a mountain of junk in your mind. ---------------------Thomas alva edison
-
I have one doubt please give me the answer. I read some where in C++, if we want to access base class constructor using derived class constructor like bellow is possible:
class base
{
base()
};class derived:public base
{
derived():base()
{
}
};normally i used like bellow
class base
{
base()
{
}
};class derived:public base
{
derived()
{
}
};My question is what is the difference between both approaches. In which cases I have to use first one and in which cases i have to use second one.
To invent something, you need a mountain of junk in your mind. ---------------------Thomas alva edison
In this case there is no differnce. But consider this case.
class base
{
base(int i)
{
}
};class derived : public base
{
derived(int j) : base(j)
{
}
};In the above case you have to explicitly call the base class constructor like this.
«_Superman_» I love work. It gives me something to do between weekends.
Microsoft MVP (Visual C++) -
I have one doubt please give me the answer. I read some where in C++, if we want to access base class constructor using derived class constructor like bellow is possible:
class base
{
base()
};class derived:public base
{
derived():base()
{
}
};normally i used like bellow
class base
{
base()
{
}
};class derived:public base
{
derived()
{
}
};My question is what is the difference between both approaches. In which cases I have to use first one and in which cases i have to use second one.
To invent something, you need a mountain of junk in your mind. ---------------------Thomas alva edison
For the example you give -- they are the same. The compiler is able to figure it out -- as "base" has a default constructor... "base()" The easiest way to see what's up here is to write both examples and run it through the debugger.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Peter Weyzen Staff Engineer [SoonR Inc -- PC Power delivered to your phone](http://www.soonr.com)
-
I have one doubt please give me the answer. I read some where in C++, if we want to access base class constructor using derived class constructor like bellow is possible:
class base
{
base()
};class derived:public base
{
derived():base()
{
}
};normally i used like bellow
class base
{
base()
{
}
};class derived:public base
{
derived()
{
}
};My question is what is the difference between both approaches. In which cases I have to use first one and in which cases i have to use second one.
To invent something, you need a mountain of junk in your mind. ---------------------Thomas alva edison
these both won't compile