1. What¡¯s overload function in C++
2. A. What¡¯s inline function in C++
B. When would you use inline function
C. Please write sample code.
3. Which of the following are legal For those usages that are illegal, explain why.
const int buf;
int cnt = 0;
const int sz = cnt;
cnt++; sz++;
4. Please point out the errors in the following C++ code. And why
switch ( ival )
{
case 1, 3, 5, 7, 9:
oddcnt++;
break;
case 2, 4, 6, 8, 10:
evencnt++;
break;
}
5. Given the following base and derived class definitions:
class Base
{
public:
foo ( int );
protected:
int _bar;
double _foo_bar;
};
class Derived: public Base
{
public:
foo ( string );
bool bar ( Base *pb );
void foobar ();
protected:
string _bar;
};
Identify what is wrong with each of the following code fragments and how each might be fixed:
(a) Derived d; d.foo ( 1024 );
(b) void Derived :: foobar () { _bar=1024; }
(c) bool Derived :: bar { Base *pb }
{ return _foo_bar = = pb->_foo_bar; }
6. A. Please list all the design patterns you known.
B. Please explain the pattern of ¡°Factory¡± and give an example if you can.
7. A. Please list all the sorting algorithms you known.
B. Please use pseudo code to describe the algorithm of ¡°Quick Sort¡±.
8. Please answer the following questions:
A. What¡¯s process scheduling and list all scheduling algorithms you known.
B. What¡¯s the ¡°Race Condition¡±
C. Please explain the diagram of process state change.