C++ Interview Questions
- 0of 0 votes
AnswerStatic members,
- Siva March 20, 2010
What are they?
Their reason of existence?
Challenges they have? (Link initilization)......| Report Duplicate | Flag | PURGE
Bloomberg LP Software Engineer / Developer C++ - 0of 0 votes
Answerswhy copy constructor must pass by reference
- Anonymous March 18, 2010| Report Duplicate | Flag | PURGE
Microsoft C++ - 0of 0 votes
Answersclass Person{ public: Person(const char* szName); const char* GetName() const; /*put a function here*/ private: char *m_szName; }; int main() { Person person("John"); std::cout << Person; return 0; }
Referring to the sample code above, which one of the following member
- diamondlcd March 18, 2010
functions do you add at the comment to support std::cout << person
statement?
A. std::string operator() { return GetName(); }
B. std::string ToString() { return GetName(); }
C. const char* Convert() const { return GetName(); };
D. char* operator char*() const { return GetName(); };
E. operator const char*() const { return GetName(); };| Report Duplicate | Flag | PURGE
Bloomberg LP Software Engineer / Developer C++ - 0of 0 votes
AnswersWhy does your class have a pure virtual function?
- diamondlcd March 18, 2010
A. To ensure that this function is overridden in derived classes
that are to be instantiated
B. To allow for templated classes to be used with friend functions
C. To maximize the memory efficiency provided that execution speed
is not at a premium
D. To maximize code reuse
E. To maximize the execution speed of the function provided that
memory is not at a premium| Report Duplicate | Flag | PURGE
Bloomberg LP Software Engineer / Developer C++ - 0of 0 votes
AnswersWhats the size of a derived object ? How would you calculate it ? Does it include size of base class size?
- guest March 15, 2010| Report Duplicate | Flag | PURGE
Bloomberg LP Software Engineer / Developer C++ - 0of 0 votes
AnswersCan you do this : Derived *d = new Base()
- guest March 15, 2010
Where base has a virtual func foo() that is also implemented in derieved.
What are the implications ? (Note: its opposite of what one does for polymorphism..)| Report Duplicate | Flag | PURGE
Bloomberg LP Software Engineer / Developer C++ - 0of 0 votes
AnswersHow do you perform error handling in destructors ? (throws Exceptions?)
- guest March 15, 2010| Report Duplicate | Flag | PURGE
Bloomberg LP Software Engineer / Developer C++ - 0of 0 votes
AnswersVirtual Functions and its implementation
- bizz March 04, 2010| Report Duplicate | Flag | PURGE
Goldman Sachs Software Engineer / Developer C++ - 0of 0 votes
AnswersHi all, I had MS interview today on campus. He asked me to implement a function readone().and also gave me an input file with lot of lines. This function readone() should read the file(just one line from the file) whenever it is called.for example, if readone() is called first time - it ll read first line, if readone() is called second time, it will read second line. Though the qn seems simple, I baffled there!:(
- Anonymous March 02, 2010| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer C C++ Coding - 0of 0 votes
Answers1. Explain OOP,classes,inheritance and polumorphism.
- guest March 02, 2010
2. Difference between C,C++.| Report Duplicate | Flag | PURGE
Bloomberg LP Financial Software Developer C++ - 0of 0 votes
AnswersWhat is the difference between a C++ array and an STL array type
- dagnihot March 01, 2010| Report Duplicate | Flag | PURGE
Apple Software Engineer / Developer C++ - 0of 0 votes
Answerschar a[] = " ";
- TopCoder February 26, 2010
Q. What will be sizeof(a)| Report Duplicate | Flag | PURGE
Bloomberg LP Software Engineer / Developer C++ - 0of 0 votes
Answersclass Foo {
- TopCoder February 26, 2010
public:
void virtual abc() throw (int , double, long) {
};
};
class DFoo : public Foo {
public :
void abc() throw (double , int , long ) {}
};
// Will it compile
int main(){
DFoo d;
return 0;
}| Report Duplicate | Flag | PURGE
Bloomberg LP Software Engineer / Developer C++ - 0of 0 votes
AnswersGo through all the C++ Qs put on careercup , in online test most of these Qs repeat .
- TopCoder February 26, 2010
// Online Test
class Someclass {
public:
int x;
public :
Someclass(int xx) : x(xx) { }
Someclass(const Someclass& a) { x = a.x ; x++;}
Someclass& operator =(const Someclass& a1) { x = a1.x ; x--;}
};
int main( )
{
/*Someclass a(4);
Someclass b = a;
}
Q. What will be output| Report Duplicate | Flag | PURGE
Bloomberg LP Software Engineer / Developer C++ - 0of 2 votes
Answers//Online Test
- TopCoder February 21, 2010
extern void print(int *ia, int sz);
void print(int *ia, int sz);
Q. Will it compile| Report Duplicate | Flag | PURGE
Bloomberg LP Financial Software Developer C++ - 0of 0 votes
Answers//Online Test
- TopCoder February 21, 2010
struct A{
int i , j;
A(int ii , int jj) :i(ii),j(ii){}
A(const A&a){
cout << a.i << a.j;
}
void operator = (const A& a){
cout <<a.i << a.j
}
};
Q. A a(1,2);
A b(2,3);
A z = (a = b);
what will be output| Report Duplicate | Flag | PURGE
Bloomberg LP Financial Software Developer C++ - 0of 0 votes
Answers//Online Test
- TopCoder February 21, 2010
class Base {
public :
virtual void method () = 0;
private :
int n;
};
void Base::method() { n = 1;}
class D1 : Base {};
class D2 : public D1{
int i;
void method() {i = 2;}
};
Q.Does it compile , what will it have to add to compile| Report Duplicate | Flag | PURGE
Bloomberg LP Financial Software Developer C++ - 0of 0 votes
Answers//online Test
- TopCoder February 21, 2010
CLASS A{
PUBLIC :
INT &I;
INT J;
A(){
INT J;
I = J;
}
};
//Where to init reference , in member init list or ctor| Report Duplicate | Flag | PURGE
Bloomberg LP Financial Software Developer C++ - 0of 0 votes
AnswersWhat is the difference between initializing values using overloaded new and the constructor???
- Saurabh February 16, 2010| Report Duplicate | Flag | PURGE
Bloomberg LP Software Engineer / Developer C++ - 0of 0 votes
Answersimplement atoi()
- myanything February 02, 2010| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer C++ - 0of 0 votes
Answersclass A1 {
- Musheka January 22, 2010
public:
int upper;
int lower;
A1( int i ) : lower( i ), upper( lower+1 ) { };
};
what is wrong with the above code?| Report Duplicate | Flag | PURGE
Software Engineer / Developer C++ - 0of 0 votes
AnswersWhat is the difference between class members and instance members?
- Anonymous January 18, 2010| Report Duplicate | Flag | PURGE
Amazon C++ - 0of 0 votes
Answers2. why need virtual function in C++?
- Anonymous January 03, 2010| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer C++ - 0of 0 votes
AnswersWhat's the difference between system calls and library functions?
- Thomas January 03, 2010| Report Duplicate | Flag | PURGE
Software Engineer / Developer C++