C++ interview questions help# Programming - 葵花宝典
I*k
1 楼
Got some C++ interview questions, but not sure the answer, can anyone here
help??
1. What's wrong with the following lines of code? Does it complie? If yes,
any problems?
class A { ... };
class B : public A { ... } // definitions of classess, these are OK
Foo() {
A & a = B(); // ??
A * p = &B(); // ??
.......
}
2. If I use malloc to get a piece of memory :
char * p = (char*)malloc (1000);
now I found that I need more than 1000 bytes, say, 1020 bytes, how to get
memory such that the newly obtaine
help??
1. What's wrong with the following lines of code? Does it complie? If yes,
any problems?
class A { ... };
class B : public A { ... } // definitions of classess, these are OK
Foo() {
A & a = B(); // ??
A * p = &B(); // ??
.......
}
2. If I use malloc to get a piece of memory :
char * p = (char*)malloc (1000);
now I found that I need more than 1000 bytes, say, 1020 bytes, how to get
memory such that the newly obtaine