The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Jul 2017 |
| Last Sign in: | 304 Weeks Ago, 4 Days Ago |
| Questions Answered: | 15833 |
| Tutorials Posted: | 15827 |
MBA,PHD, Juris Doctor
Strayer,Devery,Harvard University
Mar-1995 - Mar-2002
Manager Planning
WalMart
Mar-2001 - Feb-2009
Need help with a couple questions. I'm not very good with pulling random things out of nowhere for these questions.
This needs to be done within 2 hours! Please!
Â
1.Need code that allocates an integer on the stack and allocates another integer on the heap.
Â
2.Need an abstract base class called Item that has the following methods: equip and getName.
Â
3.Need code that dynamically allocates an array of pointers to class Foo with 10 elements. Dynamically allocate a new Foo object for each element of the array. Then, de-allocate each element, along with the array.
Â
4.Consider the following class.
class ManagedArray {
public:
float * data;
int size;
ManagedArray():data(0),size(0){}
void setSize(int a_size){ size = a_size; data = new float[size]; }
};
Overload the output operator for this class so that it prints out each element in the data array.
Â
5.Fill in the following function so that if the object pointed by "obj" is of type "Item," the If statement will trigger as true.
void printIfItem(Object * obj)
{
Â
if( ) // print if obj is an Item
{
cout << obj << " is Item" << endl;
}
}
Â
6.Write code with a pointer pointing at an instance of class of type Foo, and then typecast it to a pointer of type Bar.
Â
7.Need a class named LivingThing and another class called Frog, which inherits from LivingThing (LivingThing is the parent class and Frog is the child class).
Â
8.Write code for a class called "Integer." The Integer class should have a single int member, value. with accessors and mutators for value. The default constructor of Integer should set value to zero.
Â
9.Write code for a struct called "Napkin." The Napkin class should have a floating-point member for width and height and thickness, a c-string member for material, and an integer member for color.
Â
Â
Again thank you and time is running out...
----------- Â ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly