C++ Programming - Objects and Classes - Discussion
Discussion Forum : Objects and Classes - Programs (Q.No. 12)
12.
What will be the output of the following program?
#include<iostream.h>
class BixBase
{
public:
float x;
};
class BixDerived : public BixBase
{
public:
char ch;
void Process()
{
ch = (int)((x=12.0)/3.0);
}
void Display()
{
cout<< (int)ch;
}
};
int main()
{
class BixDerived *objDev = new BixDerived;
objDev->Process();
objDev->Display();
return 0;
}
Discussion:
1 comments Page 1 of 1.
Satheesh said:
1 decade ago
ch=(int)((x=12.0)/3.0)).
We are type casting the value 4.000000 to 4 and then ch stores the ASCII value of 4
in display function ch is type casted to integer so it displays value 4 at the end.
We are type casting the value 4.000000 to 4 and then ch stores the ASCII value of 4
in display function ch is type casted to integer so it displays value 4 at the end.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers