GlobalLogic Interview
Toplevel traversal in a BST
Class with parent virtual function defined (program)
Virtual destructor
copy constructor, copy constructor why do we give reference
Polymorphism
Frequency of characters in "globallogic"
If we declare a constructor as private, can we create an object ?
Ans: we can't create object on stack but we can create on heap using new
Even or odd using Thread coding question
https://www.toptal.com/c-plus-plus/interview-questions
class Base {
virtual void method() {std::cout << "from Base" << std::endl;}
public:
virtual ~Base() {method();}
void baseMethod() {method();}
};
class A : public Base {
void method() {std::cout << "from A" << std::endl;}
public:
~A() {method();}
};
int main(void) {
Base* base = new A;
base->baseMethod();
delete base;
return 0;
}
https://www.ambitionbox.com/interviews/globallogic-interview-questions
Round 2
------
What is function overloading ? how to distinguish 2 functions
void func(int a)
{}
void func(int a,int b=0)
{}
int main()
{
func(20);
}
What is template specialization, write a code to do function overloading using template specialization
smart pointers , difference between weak_ptr and shared_ptr
SOLID principle
Coding:-
swap bits of a single number , need to know std::bitset or vector<bool> or bitwise operators
C++11/14 features
Coding:-
Why run time polymorphism is used of it takes time for run-time (SOLID principle)
Why use run time polymorphism? (Reusability) , you can create library of parent class and do runtime linking
Tightly coupled vs weakly coupled(SOLID)
endl vs '\n'
When a complete line of output needs to be flushed, the std::endl manipulator may be used
Stages of compilation /compiler
why namespace is used ?
cin/cout vs scanf/printf difference
Ans:-
support type-safe input and output. This means that they automatically handle the conversion of data types, making it easier to read and write data in your C++ programs.
use std::ios::sync_with_stdio(false); for making cin faster than scanf
| sync_with_stdio() |
Sets whether the standard C++ streams are synchronized to the standard C streams after each input/output operation.
Comments
Post a Comment