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)

C++ Other Question

Q. What is the difference between char a[] = “string”; and char *p =
“string”;?
In the first case 6 bytes are allocated to the variable a which is fixed,
where as in the second case if *p is assigned to some other value the
allocate memory can change.
What’s the
Generate random number