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: | Apr 2017 |
| Last Sign in: | 103 Weeks Ago, 3 Days Ago |
| Questions Answered: | 4870 |
| Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
Pointer Errors and Inheritance C++Part A
1 int* p = new int;
2 p = 5;
3 *p = *p + 5;
4 Employee e1 = new Employee(“Hacker, Harry”, 34000);
5 Employee e2;
6 e2->set_salary(38000);
7 delete e2;
8 Time* pnow = new time ();
9 Time* t1 = new Time(2, 0, 0);
10 cout << t1->seconds_from(pnow);
11 delete*t1;
12 cout << t1->get_seconds();
13 Employee* e3 = new Employee(“Lin, Lisa”, 68000);
14 cout << e3.get_salary();
15 Time* t2 = new Time(1, 25, 0);
16 cout << *t2.get_minutes();
17 delete t2;
Part B
The nam
A pointer to the persons best friend
A popularity counter that indicates how many people have this person as their best friend
Part C
Class B
{
Public;
B();
B( int n);
};
B::B()
{
cout << “B::B()n”;
}
B::B(int n)
{
cout << “B::B(“ << n << “)n”;
}
Class D : Public B
{
public:
D();
D( int n);
private:
B b;
};
D::D()
{
cout << “D::D()n”;
}
D::D(int n) : B(n)
{
b = B(-n);
cout << “D::D(“<< n <<”)n”;
}
What does the following program print?
int main()
{
D d(3);
return 0;
}
Part D