1. What does the following do:
void afunction(int *x)
{
x=new int;
*x=12;
}
int main()
{
int v=10;
afunction(&v);
cout<<v;
}
a) Outputs 12
b) Outputs 10
c) Outputs the address of v
Answers were Sorted based on User's Feedback
Answer / shakti singh khinchi
ANs: b. Output is 10.
bcoz in method afunction() allocates new memory to var x and
change its value after that, but tha actual variable doesn't
changes its location, thats why its remains same as it has
initialised by 10.
But if memory allocation by "new" has not ben done than it
will change the value as 12.
| Is This Answer Correct ? | 4 Yes | 0 No |
Explain what are accessor methods?
How do we implement inheritance in c++?
What are the operators in c++?
Explain unexpected() function?
What is cloning?
class Foo { public: Foo(int i) { } }; class Bar : virtual Foo { public: Bar() { } }; Bar b; Referring to the above code, when the object 'b' is defined, a compiler error will occur. What action fixes the compiler error? a) Adding a virtual destructor to the class Bar b) Adding a constructor to Bar which takes an int parameter c) Adding "Foo()" to the Bar constructor d) Adding a copy constructor to the class Foo e) Adding "Foo(0)" to the Bar::Bar initializer list
let a,b,c be three integer numbers.write a c++ program with a function void rotate 1()such that a->b->c and c->a.
What are the methods of exporting a function from a dll?
Why is it difficult to store linked list in an array?
Explain the difference between using macro and inline functions?
Describe linked list using C++ with an example.
What is the Diffrence between a "assignment operator" and a "copy constructor"?