Самые популярные вопросы и ответы для интервью и онлайн-тесты
Образовательная платформа для подготовки к интервью, онлайн-тестов, учебных материалов и живой практики

Развивайте навыки с целевыми маршрутами обучения, пробными тестами и контентом для подготовки к интервью.

WithoutBook объединяет вопросы для интервью по предметам, онлайн-практику, учебные материалы и сравнительные руководства в одном удобном учебном пространстве.

Подготовка к интервью

Пробные экзамены

Сделать домашней страницей

Добавить страницу в закладки

Подписаться по адресу эл. почты

C++ вопросы и ответы для интервью

Test your skills through the online practice test: C++ Quiz Online Practice Test

Связанные сравнения

C vs C++Java vs C++

Вопрос 61. What is the difference between char a[] = ?string?; and char *p = ?string?; ?


Answer1
a[] = ?string?;
char *p = ?string?;

The difference is this:
p is pointing to a constant string, you can never safely say
p[3]=?x';
however you can always say a[3]=?x';

char a[]=?string?; - character array initialization.
char *p=?string? ; - non-const pointer to a const-string.( this is permitted only in the case of char pointer in C++ to preserve backward compatibility with C.)

Answer2
a[] = ?string?;
char *p = ?string?;

a[] will have 7 bytes. However, p is only 4 bytes. P is pointing to an adress is either BSS or the data section (depending on which compiler ? GNU for the former and CC for the latter).

Answer3
char a[] = ?string?;
char *p = ?string?;

for char a[]??.using the array notation 7 bytes of storage in the static memory block are taken up, one for each character and one for the terminating nul character.

But, in the pointer notation char *p????.the same 7 bytes required, plus N bytes to store the pointer variable ?p? (where N depends on the system but is usually a minimum of 2 bytes and can be 4 or more)??

Это полезно? Добавить комментарий Посмотреть комментарии
 

Вопрос 62. What does extern mean in a function declaration?


It tells the compiler that a variable or a function exists, even if the compiler hasn?t yet seen it in the file currently being compiled. This variable or function may be defined in another file or further down in the current file.

Это полезно? Добавить комментарий Посмотреть комментарии
 

Вопрос 63. How do I initialize a pointer to a function?

This is the way to initialize a pointer to a function
void fun(int a)
{

}

void main()
{
void (*fp)(int);
fp=fun;
fp(1);

}

Это полезно? Добавить комментарий Посмотреть комментарии
 

Вопрос 64. How do you link a C++ program to C functions?


By using the extern "C" linkage specification around the C function declarations.

Это полезно? Добавить комментарий Посмотреть комментарии
 

Вопрос 65. Explain the scope resolution operator.


It permits a program to reference an identifier in the global scope that has been hidden by another identifier with the same name in the local scope.

Это полезно? Добавить комментарий Посмотреть комментарии
 

4) How do you link a C++ program to C functions? 5) Explain the scope resolution operator. " />

Самое полезное по оценкам пользователей:

Авторские права © 2026, WithoutBook.