Hello, I have this worksheet to do for my CSCI class. I just need some help on a few questions. I have my own answers to them but I would like some expert help.

1. string *str;
*str= “12345”;

will the above code segment work as expected?
Why?

2. int *k;
char c;
k=&c;

will the above code segment work? Why?

3.class Base{
public:
void public_foo();
private:
void private_foo();
protected:
void protected_foo();
};

class Derived{
public:
void der_public_foo();
void process();
private:
void der_private_foo();
protected:
void der_protected_foo();
};

Base b1, *b2;
Derived d1, *d2;

For each of the following statements, indicate
valid/invalid and if invalid,
explain clearly why.

a) b2 = &d1;

b) d2 = &b1;

c) d2 = &d1;
d2->der_protected_foo();

d) d2 = &d1;
d2->public_foo();

e) b2 = &d1;
b2->der_public_foo();

f) The following is an implementation of
Derived:rocess()
void Derived:rocess()
{
Base:rotected_foo();
Base:rivate_foo();
}

4. Write a recursive function to print a decimal
number in reverse order. E.G.: 12345 would be printed as 54321. Note that the input is an integer, not a string. Hint: Use the / and % operators.


Enhance the trance,
April