C++
Programming and Technical
Programming
Program
What will be the output for the following C++ program ..??
class Sample
{
public:
int *ptr;
Sample(int i)
{
ptr = new int(i);
}
~Sample()
{
delete ptr;
}
void PrintVal()
{
cout << "The value is " << *ptr;
}
};
void SomeFunc(Sample x)
{
cout << "Say i am in someFunc " << endl;
}
int main()
{
Sample s1= 10;
SomeFunc(s1);
s1.PrintVal();
}
Read Solution (Total 4)
-
- Say i am in someFunc
The value is 10 - 10 years agoHelpfull: Yes(4) No(3)
- ANS:
Say i am in someFunc
The value is 0
- 10 years agoHelpfull: Yes(0) No(1)
- Output :
Say i am in someFunc.
The value is :10
Null Pointer assignment
- 10 years agoHelpfull: Yes(0) No(0)
- Say i am in someFunc
The value is 0 - 9 years agoHelpfull: Yes(0) No(0)
C++ Other Question