贴个FLEXTRADE的在线C++测试的题# JobHunting - 待字闺中
c*2
1 楼
面的是Associate C++ Developer,下面是面试题,光顾着记题了,最后只有56%的通过
率,要到
80%才能ONSITE,算是帮大家做点贡献吧,他家在招人,赶快去投简历
1) #include
using namespace std;
struct A{
A(int value) : m_value(value){}
int m_value;
};
struct B:A {
B(int value):A(value){}
};
int main(){
try {
try{
throw B(5);
}
catch(A a){
a.m_value *=2;
throw;
}
catch(B b){
b.m_value -=2;
throw b;
}
}
catch(A a){
std::cout << a.m_value;
}
return 0;
}
output?
2)how to declare a pointer to class member
3) #include
using namespace std;
struct Foo{
Foo() {std::cout <Foo(int i) {std::cout <Foo(char c) {std::cout <Foo(long l) {std::cout <Foo(float f) {std::cout<};
int main(){
Foo f1('a');
Foo f2('a'+1);
Foo f3(1);
Foo f4(0x01);
Foo f5(0X0001L);
Foo f6(1.0f);
system("pause");
return 0;
}
output?
4) #include
using namespace std;
int main(){
int a = 2|1;
cout << a;
system("pause");
return 0;
}
5)
class X{
public:
X& operator=(const X& rhs);
const X& operator+(const X&rhs) const;
const X& operator+(int m);
private:
int n;
};
int main(){
X a, b, c;
system("pause");
return 0;
}
which one is wrong?
a=c+5;
a=a=b+c;
(a=c+4)=b+2;
a=b+c;
b=a+1;
6) class foo{
public:
foo(int i){}
};
class bar: virtual foo{
public:
bar(){}
};
bar b;
what's wrong with the above code?
7) class deriv2: public mybase, devive1{}
is this correct?
8) ++ operator overload prefix & postfix, dummy parameter, both
prefix&postfix
forget....
9) int main(){
int c=0;
if(c=(c!=1)){}
cout < system("pause");
return 0;
}
output?
10)int main(){
int a=5;
int b=a++;
int c=++a;
a=b*c;
cout <system("pause");
return 0;
}
output?
11) template<> class Stack
{
public:
int push(char);
char pop();
};
what template<> signify in this exmple class ?
template queue
default template initialization
emplty template declaration
others
12) F00
| |
BAR BAR2
| |
FOOBAR FOOBAR2
dynamic cast foo to children
率,要到
80%才能ONSITE,算是帮大家做点贡献吧,他家在招人,赶快去投简历
1) #include
using namespace std;
struct A{
A(int value) : m_value(value){}
int m_value;
};
struct B:A {
B(int value):A(value){}
};
int main(){
try {
try{
throw B(5);
}
catch(A a){
a.m_value *=2;
throw;
}
catch(B b){
b.m_value -=2;
throw b;
}
}
catch(A a){
std::cout << a.m_value;
}
return 0;
}
output?
2)how to declare a pointer to class member
3) #include
using namespace std;
struct Foo{
Foo() {std::cout <Foo(int i) {std::cout <Foo(char c) {std::cout <Foo(long l) {std::cout <Foo(float f) {std::cout<};
int main(){
Foo f1('a');
Foo f2('a'+1);
Foo f3(1);
Foo f4(0x01);
Foo f5(0X0001L);
Foo f6(1.0f);
system("pause");
return 0;
}
output?
4) #include
using namespace std;
int main(){
int a = 2|1;
cout << a;
system("pause");
return 0;
}
5)
class X{
public:
X& operator=(const X& rhs);
const X& operator+(const X&rhs) const;
const X& operator+(int m);
private:
int n;
};
int main(){
X a, b, c;
system("pause");
return 0;
}
which one is wrong?
a=c+5;
a=a=b+c;
(a=c+4)=b+2;
a=b+c;
b=a+1;
6) class foo{
public:
foo(int i){}
};
class bar: virtual foo{
public:
bar(){}
};
bar b;
what's wrong with the above code?
7) class deriv2: public mybase, devive1{}
is this correct?
8) ++ operator overload prefix & postfix, dummy parameter, both
prefix&postfix
forget....
9) int main(){
int c=0;
if(c=(c!=1)){}
cout <
return 0;
}
output?
10)int main(){
int a=5;
int b=a++;
int c=++a;
a=b*c;
cout <system("pause");
return 0;
}
output?
11) template<> class Stack
{
public:
int push(char);
char pop();
};
what template<> signify in this exmple class ?
template queue
default template initialization
emplty template declaration
others
12) F00
| |
BAR BAR2
| |
FOOBAR FOOBAR2
dynamic cast foo to children