C++ Programming - Constructors and Destructors - Discussion
Discussion Forum : Constructors and Destructors - Programs (Q.No. 6)
6.
Which of the following statement is correct about the program given below?
#include<iostream.h>
class IndiaBix
{
int *p;
public:
IndiaBix(int xx, char ch)
{
p = new int();
*p = xx + int(ch);
cout<< *p;
}
~IndiaBix()
{
delete p;
}
};
int main()
{
IndiaBix objBix(10, 'B');
return 0;
}
Discussion:
9 comments Page 1 of 1.
Raj said:
7 years ago
*p is not print address it prints value of p=10+66=76.
Madhu said:
7 years ago
It Should print some garbage value I guess as *p prints address.
Please, someone revert back to clear this doubt.
Please, someone revert back to clear this doubt.
DOMINIC said:
8 years ago
BECAUSE ASCII VALUE OF B is 066.
Rohit said:
9 years ago
How output comes to 76? It's only because ASCII value of B is 66.
Ravi said:
1 decade ago
@Akanksha.
Char to integer conversion: We have built in ASCII value range i.e. A to Z is 65 to 90. So here in above program we have 'B' that's mean its integer value is 66.
Char to integer conversion: We have built in ASCII value range i.e. A to Z is 65 to 90. So here in above program we have 'B' that's mean its integer value is 66.
Anon said:
1 decade ago
Shouldn't p be assigned to an address in c as in p=&a ?
Akanksha said:
1 decade ago
How to convert character into integer?
Balu said:
1 decade ago
Pointer variable print the address of the content then how it prints the value?
Minni said:
1 decade ago
Here the character is converted into int i.e. 'B'=66 which is added to the xx value 10 and thus we get the output 76.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers