Mail Archives: djgpp/1997/11/30/22:48:01
Hi. I seem to have run into another difference between Borland TurboC++ Lite
and djgpp. I am using RHIDE1.4 as a UI. The point of the code below was to
see how constructors pass values through parameters, stepping through the code
with F7 and watching the data members d.b1, d.b2, and d.d1.
When you use TC Lite, the watch window shows that...
d.b1: 1
d.b2: 2
d.d1: 3
...the values have been set as expected by the time the highlight gets to the
getch function in main.
The watch window in RHIDE, however, shows that...
d.b1: not available
d.b2: not available
d.d1: 3
...yet both statements are printed to the user screen:
in base constructor
in deriv constuctor
...so both constructors are working. When stepping through the code with F7
using TCLite, you see it step through the base constructor, but you don't when
using RHIDE.
Does anyone know what the difference is? Here's the code I'm using:
/*----------- T.cc
only slightly modified from M. Rinehart's code
for learning about constuctors
------------*/
#include <conio.h>
class Base
{
private:
int b1, b2;
public:
Base(int p1, int p2);
};
class Deriv : Base
{
private:
int d1;
public:
Deriv(int p1, int p2, int p3);
};
int main()
{
clrscr();
Deriv d(1,2,3);
getch();
return 0;
}
Base::Base(int p1, int p2)
{
b1 = p1;
b2 = p2;
cprintf("in base constructor\n\r");
}
Deriv::Deriv(int p1, int p2, int p3):Base(p1,p2)
{
d1 = p3;
cprintf("in deriv constuctor\n\r");
}
// end
- Raw text -