make a program output
// the values of:
//
// * `thing->x`
// * `thing->y`
// * `thing->foo()`
// * `thing->bar()`
using namespace std;
class Thing
{
private:
int x;
int y;
virtual int foo()
{
return x + y;
}
virtual int bar()
{
return x*y;
}
public:
Thing() {
x = 2;
y = 10;
}
};
int extract_x(void *thing)
{
Thing thing;
Thing();
cout << x;
return 0;
}
int extract_y(void *thing)
{
Thing thing;
Thing();
cout << y;
return 0;
// --- End your code ---
}
int call_foo(void *thing)
{
// --- Begin your code ---
return 0;
// --- End your code ---
}
int call_bar(void* thing)
{
// --- Begin your code ---
return 0;
// --- End your code ---
}
int main()
{
Thing thing;
std::printf("%d %d %d %d\n",
extract_x(&thing),
extract_y(&thing),
call_foo(&thing),
call_bar(&thing));
system("pause");
return 0;
}
Here I am trying to create new object and the grab the variables in the Thing class but it still does not work. Says that x is undefined. I am not supposed to touch anything but the bodies of extraxt_x,extract_y,call_foo, and call_bar