Principais perguntas e respostas de entrevista e testes online
Plataforma educacional para preparacao de entrevistas, testes online, tutoriais e pratica ao vivo

Desenvolva habilidades com trilhas de aprendizado focadas, simulados e conteudo pronto para entrevistas.

WithoutBook reune perguntas de entrevista por assunto, testes praticos online, tutoriais e guias comparativos em um unico espaco de aprendizado responsivo.

Preparar entrevista

Simulados

Definir como pagina inicial

Adicionar esta pagina aos favoritos

Assinar endereco de e-mail

C++ perguntas e respostas de entrevista

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

Diferencas relacionadas

C vs C++Java vs C++

Pergunta 11. What is public, protected, private?

Public, protected and private are three access specifier in C++.
Public data members and member functions are accessible outside the class.
Protected data members and member functions are only available to derived classes.
Private data members and member functions can?t be accessed outside the class. However there is an exception can be using friend classes.
Write a function that swaps the values of two integers, using int* as the argument type.
void swap(int* a, int*b) {
int t;
t = *a;
*a = *b;
*b = t;
}

Isto e util? Adicionar comentario Ver comentarios
 

Pergunta 12. Tell how to check whether a linked list is circular.


Create two pointers, each set to the start of the list. Update each as follows:

Isto e util? Adicionar comentario Ver comentarios
 

Pergunta 13. OK, why does this work?


If a list is circular, at some point pointer2 will wrap around and be either at the item just before pointer1, or the item before that. Either way, it?s either 1 or 2 jumps until they meet.

Isto e util? Adicionar comentario Ver comentarios
 

Pergunta 14. What is virtual constructors/destructors?


Answer1
Virtual destructors:
If an object (with a non-virtual destructor) is destroyed explicitly by applying the delete operator to a base-class pointer to the object, the base-class destructor function (matching the pointer type) is called on the object.
There is a simple solution to this problem declare a virtual base-class destructor.
This makes all derived-class destructors virtual even though they don?t have the same name as the base-class destructor. Now, if the object in the hierarchy is destroyed explicitly by applying the delete operator to a base-class pointer to a derived-class object, the destructor for the appropriate class is called. Virtual constructor: Constructors cannot be virtual. Declaring a constructor as a virtual function is a syntax error.

Answer2
Virtual destructors: If an object (with a non-virtual destructor) is destroyed explicitly by applying the delete operator to a base-class pointer to the object, the base-class destructor function (matching the pointer type) is called on the object.
There is a simple solution to this problem ? declare a virtual base-class destructor. This makes all derived-class destructors virtual even though they don?t have the same name as the base-class destructor. Now, if the object in the hierarchy is destroyed explicitly by applying the delete operator to a base-class pointer to a derived-class object, the destructor for the appropriate class is called.

Isto e util? Adicionar comentario Ver comentarios
 

Pergunta 15. Virtual constructor: Constructors cannot be virtual. Declaring a constructor as a virtual function is a syntax error. Does c++ support multilevel and multiple inheritance?


Yes.

Isto e util? Adicionar comentario Ver comentarios
 

2) Tell how to check whether a linked list is circular. 3) OK, why does this work? 4) What is virtual constructors/destructors? 5) Virtual constructor: Constructors cannot be virtual. Declaring a constructor as a virtual function is a syntax error. Does c++ support multilevel and multiple inheritance? " />

Mais uteis segundo os usuarios:

Copyright © 2026, WithoutBook.