C++ Interview Questions
- 0of 0 votes
AnswerWhen is a template a better solution than a base class?
- Rats May 07, 2011| Report Duplicate | Flag | PURGE
HCL Software Engineer / Developer C++ - 0of 0 votes
AnswersHello
- Anonymous May 06, 2011
Suppose I have set of files and in every files there are include# to other files in the same set.Suppose I have function that load all the includes in certain file.I need to write function that load all the includes in some given source file so I will avoid infinite loop and circular call for the include.
To solve the question I have to use this function i can't use pragma once or something similar I think it could be solved by recursion though I am not sure how
Thank you| Report Duplicate | Flag | PURGE
Intel Software Engineer / Developer C++ - 0of 0 votes
Answerswhat is the difference between
- Anonymous May 05, 2011T *o = new T and T *o = new T()
| Report Duplicate | Flag | PURGE
Bloomberg LP Software Engineer / Developer C++ - 0of 0 votes
AnswersWhat are the different types of cast in C++? Difference between static, dynamic, reinterpret cast.
- Nupur April 28, 2011| Report Duplicate | Flag | PURGE
Goldman Sachs Developer Program Engineer C++ - 0of 0 votes
AnswersDifference between pointer and reference. Can a NULL pointer be used as a reference?
- Nupur April 28, 2011| Report Duplicate | Flag | PURGE
Goldman Sachs Developer Program Engineer C++ - 0of 0 votes
AnswersDesign a reference counted smart pointer.
- Hemant Parashar April 18, 2011| Report Duplicate | Flag | PURGE
Goldman Sachs Software Engineer / Developer C++ - 0of 0 votes
AnswersHow will you do inheritance in C without using any C++ constructs?
- A M April 12, 2011| Report Duplicate | Flag | PURGE
A9 Software Engineer / Developer C C++ - 0of 0 votes
AnswersWhat is the size of a class which will have only one function declaration as public. And what is the size of a class if that the same function is declared as virtual.
- viswathsen April 10, 2011class Myclass { public: int fun(); }; Sizeof(Myclass) ?? And class Myclass { public: vitual int fun(); }; Sizeof(Myclass) ??
| Report Duplicate | Flag | PURGE
IBM Developer Program Engineer C++ - 0of 0 votes
AnswersWrite a ‘translator’ program to convert a string (in C++ or other
- Anonymous March 27, 2011
language) into something which can be applied to the ‘where’ clause in sql
‘select’, here the string can be evaluated to a Boolean value, eg aa==3 &
& bb>12 || …| Report Duplicate | Flag | PURGE
Bloomberg LP C++ - 0of 0 votes
AnswersWHY (specifically WHY) do we have virtual functions (not just to access derived class methods using base class object. why we have to do that?
- Krish March 09, 2011
Ans: Library implementation or force interface approach by declaring a pure virtual function where user is forced to implement it, as is the case with interface.| Report Duplicate | Flag | PURGE
NetApp Software Engineer / Developer C++ - 0of 0 votes
AnswersDifference between Java and C++?
- Krish March 09, 2011| Report Duplicate | Flag | PURGE
NetApp Bloomberg LP Financial Software Developer Software Engineer / Developer C C++ Java - 0of 0 votes
Answersimplement atoi function.
- CGB (3rd Telephone Interview) February 24, 2011| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer C++ - 0of 0 votes
AnswersHow does a compilier work?
- Anonymous February 22, 2011| Report Duplicate | Flag | PURGE
JP Morgan Software Engineer / Developer C++ - -1of 1 vote
Answersoutput of following Program
- RS February 19, 2011
class A
{
public:
virtual void Fun1(int no=10)
{
cout<<"A::Fun1";
}
};
class B
{
public:
virtual void Fun1(int no=20)
{
cout<<"B::Fun1()";
}
}
int main()
{
B b;
A &a =b;
a.Fun1();
}| Report Duplicate | Flag | PURGE
Goldman Sachs Software Engineer / Developer C++ - 0of 0 votes
AnswersCreate a Singleton class which has only one static method? static variable or new is not allowed
- ajit February 19, 2011| Report Duplicate | Flag | PURGE
MAGMA C++ - 0of 0 votes
Answers<round 2>
- siva.sai.2020 February 16, 2011
14) How you will achieve encapsulation in C language ?.| Report Duplicate | Flag | PURGE
MAGMA Software Engineer / Developer C++ - 0of 0 votes
Answers<round 2>>
- siva.sai.2020 February 16, 2011
13. Different types of TYPECASTS in C++ ?| Report Duplicate | Flag | PURGE
MAGMA Software Engineer / Developer C++ - 0of 0 votes
AnswersWhat difference in behavior you find between Virtual destructors and other virtual functions and why?
- aaptuster February 14, 2011| Report Duplicate | Flag | PURGE
Amazon Developer Program Engineer C++ - 0of 0 votes
Answers4) How to initialize Constant variables in class( or object).
example 1: throws error "uninitialized member 'myclass::i' with 'const' type 'const int'
"#include <iostream> using namespace std; class myclass{ public: const int i; myclass() { i = 10; // here throws error } }; int main() { myclass m; cout<<m.i<<endl; return 0; }
example 2: below piece of code works fine .
#include <iostream> using namespace std; class myclass{ public: const int i; myclass() : i(10) { } }; int main() { myclass m; cout<<m.i<<endl; return 0; }
Can some one please explain me , why second example works fine ? . why not first example ?
- siva.sai.2020 February 13, 2011| Report Duplicate | Flag | PURGE
Gluster Software Engineer / Developer C++ - 0of 0 votes
AnswersWhat are the mandatory conditions when compiler synthesizes the constructors.
- RS February 13, 2011| Report Duplicate | Flag | PURGE
Goldman Sachs Software Engineer / Developer C++ - 0of 0 votes
Answersclass Foo
- RS February 13, 2011
{
int a;
public :
virtual void Fun1() {};
};
Class X
{
Foo f;
public:
X()
{
memset(&f,0x0,sizeof(f);
}
}
int main()
{
X x;
}
Is there any problem in this code snippet. if yes what are the problems.| Report Duplicate | Flag | PURGE
Goldman Sachs Software Engineer / Developer C++ - 0of 0 votes
AnswersWhat are the differences between new (in C++) & malloc (in).
- Rahul February 10, 2011| Report Duplicate | Flag | PURGE
Synopsys R&D Bloomberg LP Financial Software Developer C++ - 0of 0 votes
AnswersThe scenario was something like that:
- Praveen February 10, 2011
You have to create a graph in most efficient way from relationship of nodes read from txt file.
text file contains information like:
node_id weight node_id
node_id weight node_id
.....
// which means two nodes are connected with some weight. (undirected)
There are around 600K such information for about 65000 nodes.
Aim is to create a a subgraph for a given node_id. i.e for that node_id find ALL successor nodes with level mentioned i.e form a subgraph for that node.
He was looking for c++ code and most efficient algorithm.
Inputs are invited.| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer C++ - 0of 0 votes
AnswersWhat is virtual function?
- sbtech8 January 26, 2011| Report Duplicate | Flag | PURGE
Goldman Sachs Analyst C++ - 0of 0 votes
Answerscall by reference, call by value.
- sbtech8 January 26, 2011| Report Duplicate | Flag | PURGE
Goldman Sachs Analyst C++ - 0of 0 votes
AnswersDifference between set, list.
- sbtech8 January 26, 2011| Report Duplicate | Flag | PURGE
Goldman Sachs Analyst C++