YOYO,我快疯了,为啥等了快一小年都没有面试呢?# EB23 - 劳工卡
u*o
1 楼
话说我前几天去了学校的campus fair, 看到了nvidia的小booth那里在发卷子做题。现
场那个火爆呀,6个座位永远是满满的,很多人站着答,我才知道这家真是popular呀。
我要了一份卷子,发现好几题都不会。。就没交卷,现在和大家分享一下。因为需要我
一点点打字,所以我只写有点难度的吧。
1. what will be printed by the following code
struct Object{
unsigned char x, y, z, w;
};
int main(){
Object obj;
obj.x = 0x11;
obj.y = 0x22;
obj.z = 0x33;
obj.w = 0x44;
char* p = &obj;
for(int i=0; i<4; i++){
printf("%0xn",*((unsigned short*)++p));
}
return 0;
}
话说这能compile吗? char* p = &obj; 这句用char pointer指obj的地址,看得我很
苦恼呀
2. explain difference between is-a and has-a relationship, if you have a
list class and want to build a queue class, which of the relationship would
you use and why?
我赶脚着是has-a, 对吗?
3. what's wrong with this code, find at least 3 mistakes
class TrackedObject{
struct Position{
int x;
int y;
}
Position p;
const int id;
void display(){
cout << id <}
};
struct Car: TrackedObject{
int color;
};
void doStuff(const Car &theCar){
theCar.display();
}
int main(){
Car c;
c.id = 9;
c.Position = (100,200);
c.color = 1;
doStuff(c);
}
这个感觉const Car &theCar不太对,这里的inheritance有点问题吧?
c.id = 9; 这个也不对吧,c既然是const,应该不能改的?
还有啥? 我基础语法知识不行,各种oop看的我头大。。。
场那个火爆呀,6个座位永远是满满的,很多人站着答,我才知道这家真是popular呀。
我要了一份卷子,发现好几题都不会。。就没交卷,现在和大家分享一下。因为需要我
一点点打字,所以我只写有点难度的吧。
1. what will be printed by the following code
struct Object{
unsigned char x, y, z, w;
};
int main(){
Object obj;
obj.x = 0x11;
obj.y = 0x22;
obj.z = 0x33;
obj.w = 0x44;
char* p = &obj;
for(int i=0; i<4; i++){
printf("%0xn",*((unsigned short*)++p));
}
return 0;
}
话说这能compile吗? char* p = &obj; 这句用char pointer指obj的地址,看得我很
苦恼呀
2. explain difference between is-a and has-a relationship, if you have a
list class and want to build a queue class, which of the relationship would
you use and why?
我赶脚着是has-a, 对吗?
3. what's wrong with this code, find at least 3 mistakes
class TrackedObject{
struct Position{
int x;
int y;
}
Position p;
const int id;
void display(){
cout << id <}
};
struct Car: TrackedObject{
int color;
};
void doStuff(const Car &theCar){
theCar.display();
}
int main(){
Car c;
c.id = 9;
c.Position = (100,200);
c.color = 1;
doStuff(c);
}
这个感觉const Car &theCar不太对,这里的inheritance有点问题吧?
c.id = 9; 这个也不对吧,c既然是const,应该不能改的?
还有啥? 我基础语法知识不行,各种oop看的我头大。。。