Embedded C/C++ Specialized Test Questions

As we all know, embedded engineers are currently a popular position. However, finding a high-paying job in the embedded field is not so easy, especially since some companies’ interview questions are often bizarre. To address this issue, Huqing Yuanjian has compiled some specialized test questions related to embedded C/C++, hoping to help everyone. A friendly reminder, the reference answers are at the end of the questions!

1. Under linux+gcc, which of the following about the code is incorrect? ____.

std::string& test_str()

{

std::string str=”test”;

return str;

}

int main()

{

std::string& str_ref=test_str();

std::cout<<str_ref<<std::endl;< p=”” style=”margin-right: auto; margin-left: auto;”></str_ref<<std::endl;<>

return 0;

}

A Compilation warning

B Returning a reference to a local variable, runtime unknown error

C Compiles and runs normally

D After removing all & in the code, the program can run normally

2. Assuming the definition statement of a two-dimensional array is “int a[3][4]={{3,4},{2,8,6}};”, the value of element a[2][1] is ____.

A 0

B 4

C 8

D 6

3. Which of the following is the correct syntax for the sort template?

A void sort(class A first, class A last, class B pred)

B void template(class A, class B)sort(A first, A last, B pred)

C template void sort(A first, A last, B pred)

D template void sort(A first, A last, B pred)

4. Which of the following statements is correct?

A Any existing operator in C++ can be overloaded

B const objects can only call const type member functions

C Both constructors and destructors can be virtual functions

D Function overloading must have the same return type

5. If there is the following function call:

? fun(a+b,?3,?max(n-1,?b));? The number of actual parameters is ____.

A 3

B 4

C 5

D 6

6. Under the concurrent execution of two equivalent threads, where a is a global variable initialized to 0, assuming printf, ++, — operations are atomic, which output is definitely not possible?

void foo() {

if(a <= 0) {

a++;

}

else {

a–;

}

printf(“%d”, a);

}

A 01

B 10

C 12

D 22

7. In a 32-bit operating system with gcc compiler environment, the running result of the following program is ____.

#include

using namespace std;

class A {

public:

int b;

char c;

virtual void print() {

cout << “this is father’s function! ” << endl;

}

};

class B: A {

public:

virtual void print() {

cout << “this is children’s function! ” << endl;

}

};

int main(int argc, char * argv[]) {

cout << sizeof(A) << ” ” << sizeof(B) << endl;

return 0;

}

A 8 8

B 9 9

C 12 12

D 12 16

8. What is the difference between overload and override?

A Overloading: allows multiple functions with the same name to exist, but with different parameter lists

B Overloading: refers to the subclass redefining the method of the base class virtual function

C Overriding: refers to the subclass redefining the method of the base class virtual function

D Overriding: allows multiple functions with the same name to exist, but with different parameter lists

Reference answers: 1~8: C A D B A A C AC

【Weekly Hot ArticlesRecommended

1.How Can Programmers Write Good Code?

2.20 Linux Command Interview Q&A

3.Summary of TCP Knowledge Points

4.Things About Fresh Graduates’ Interviews

5.Tencent Software Development Interview Questions with Multiple Choices

6.Seven Characteristics of Excellent Programmers, How Many Do You Have?

Follow Huqing Maker Online WeChat public account,

to get more information on smart hardware development.

WeChat ID: maker-edu

Embedded C/C++ Specialized Test Questions

Long press the QR code to follow me

Leave a Comment