- How do you check whether a linked list is circular?
- How do you decide which integer type to use?
- How do you differentiate between a constructor and destructor?
- How do you differentiate between aggregation and association?
- How do you find out the size of a class?
- How do you implement an itoa function?
- How do you initialize a pointer to a function?
- How do you link a C++ program to C functions?
- How do you return a structure from functions?
- How do you write a function that can reverse a linked-list?
- What are the benefits of using exceptions in C++?
- What are the differences between a struct and a class in C++?
- What are the different types of Storage classes?
- What do you mean by inline function?
- What does extern mean in a function declaration?
- What does extern mean in a function declaration?
- What does it mean to declare a function or variable as static?
- What is a conversion constructor?
- What is a copy constructor?
- What is a namespace?
- What is a pure virtual function?
- What is a scope resolution operator?
- What is abstraction?
- What is difference between #define and const?
- What is difference between function overloading and overriding?
- What is encapsulation?
- What is function overloading?
- What is multiple inheritance?
- What is operator overloading?
- What is partial specialization or template specialization?
- What is polymorphism?
- What is the difference between “passing by value” and “passing by reference”?
- What is the difference between an object and a class?
- What is the difference between declaration and definition?
- What is the difference between declaration and definition?
- What is the difference between delete and delete[]?
- What is the difference between inner class and abstract class?
- What is the difference between persistent & non-persistent objects?
- What is the difference between structure and union?
- What is the difference between the deep copy and shallow copy?
- What is the difference between the private public and protected members?
- What is the maximum size that an array can hold?
- What is the most efficient way to reverse a linked-list?
- What is the size of an empty class?
- What is the use of virtual destructor?
- What is virtual class and friend class?
- What’s the best way to declare and define global variables?
- Where is memory for class-object allocated?
- Where is memory for struct allocated?
- Why an array always starts with index zero in C++?
Thursday, December 9, 2010
C++ Basic Interview Questions
Wednesday, November 3, 2010
C++ Series - Interview questions
How to prevent a class from inheritance ?
) Private Constructor(s)
class CBase
{ public:
static CBase* CreateInstance()
{
CBase* b1 = new CBase();
return b1;
}
private:
CBase() { }
CBase(CBase3) { }
CBase& operator=(CBase&) { }
};
2) Using CSealed base class, private ctor & virtual inheritance
class CSealed
{ private:
CSealed() {
}
friend class CBase;
};
class CBase : virtual CSealed
{
public:
CBase() {
}
};
3) Using a CSealed base class, protected ctor & virtual inheritance
class CSealed
{
protected:
CSealed() {
}
};
class CBase : virtual CSealed
{
public:
CBase() { }
};
C++ Series - Interview questions
What are the various reasons to use virtual destructor in base class?
1. Without a virtual destructor the proper destructor may not be
called:
struct B {~B();};
struct D : B {~D();};
B* b new D;
delete b; // <--------- Will not call D::~D() !!!!!
2. Without a virtual destructor operator delete(void* size_t) may
not be called with the correct size.
struct B {~B(); operator delete(void* size_t);};
struct D : B {~D();};
B* b new D;
delete b; // <--------- Will call operator delete(void* size_t) with
// the size of B not the size of D!!!
3. Without a virtual destructor and when MI is used operator
delete(void*) or operator delete (void* size_t) may be called with
the wrong address.
struct B {~B();};
struct A {};
struct D : A B {~D();};
B* b new D;
delete b; // <--------- May not pass to operator delete the address
// that was returned by operator new!!!
1. Without a virtual destructor the proper destructor may not be
called:
struct B {~B();};
struct D : B {~D();};
B* b new D;
delete b; // <--------- Will not call D::~D() !!!!!
2. Without a virtual destructor operator delete(void* size_t) may
not be called with the correct size.
struct B {~B(); operator delete(void* size_t);};
struct D : B {~D();};
B* b new D;
delete b; // <--------- Will call operator delete(void* size_t) with
// the size of B not the size of D!!!
3. Without a virtual destructor and when MI is used operator
delete(void*) or operator delete (void* size_t) may be called with
the wrong address.
struct B {~B();};
struct A {};
struct D : A B {~D();};
B* b new D;
delete b; // <--------- May not pass to operator delete the address
// that was returned by operator new!!!
C++ Series - design patterns - 1
Singleton design pattern - Most commonly used pattern and most powerful pattern if used properly.
To say about this design pattern in a single sentence ...
This patterns help to create and use a single object instance through your entire program no matter how many time your initiate your class object.
As simple implementation of this is as below:
class DBconnector{
public:
static DBconnector* Instance(); -- This function is used to create the object and return the pointer of the object to be used. If the object already exists it just returns the pointer.
bool openDBconnection(std::string logFile);
bool inserttoDB();
bool extractfromDB();
private:
DBconnector(){}; // The default ctor is made private so that an object cannot be created by just instantiating the class.
DBconnector(DBconnector const&){}; // copy constructor is made private so that fails in creating an intermediate object while copying and help to prevent only single instance is prevailing at all moment of time.
DBconnector& operator=(DBconnector const&){}; // assignment operator so it fails while assigning any other object to this instance.
static DBconnector* m_pInstance; // Pointer to the actual object , which is single through the program.
};
Multi threading issues with the above program:
Coming soon .. Keep watching.
To say about this design pattern in a single sentence ...
This patterns help to create and use a single object instance through your entire program no matter how many time your initiate your class object.
As simple implementation of this is as below:
class DBconnector{
public:
static DBconnector* Instance(); -- This function is used to create the object and return the pointer of the object to be used. If the object already exists it just returns the pointer.
bool openDBconnection(std::string logFile);
bool inserttoDB();
bool extractfromDB();
private:
DBconnector(){}; // The default ctor is made private so that an object cannot be created by just instantiating the class.
DBconnector(DBconnector const&){}; // copy constructor is made private so that fails in creating an intermediate object while copying and help to prevent only single instance is prevailing at all moment of time.
DBconnector& operator=(DBconnector const&){}; // assignment operator so it fails while assigning any other object to this instance.
static DBconnector* m_pInstance; // Pointer to the actual object , which is single through the program.
};
Multi threading issues with the above program:
Coming soon .. Keep watching.
Tuesday, November 2, 2010
Article Series - Does cloud computing change IT architecture in Banking
Over the past one year , i have been hearing about the word "Cloud Computing" from many technology companies. There was attending seminars over a couple on months on cloud computing in Singapore and i find two of them very interesting.
First one was from MAS (Monetary Authority of Singapore) at SMU and second was from Amazon web services the largest provider of cloud computing services. Each of them have totally opposite opinion on cloud computing.
To tell you some thing about cloud computing in one sentence , it a computing service exposed to public over internet. That means , you have to pay for the usage of service and only pay as much as you use the service. Just like your utility bill. As in the case of utilities like water and electricity , the user are unaware of how the drinking water , from where did the drinking water come from , similar is the case with Cloud Computing , the user will be unaware of how is the underlying IT infrastructure scaled , or where is the IT infrastructure available , they just use the service and pay for it.
The MAS speaker was concerned about the banks to expose their data on a public cloud. Banks can save a lot of money , if they are able to minimize the cost of their operations. When they start to use the cloud , they can pay as less as 5 USD per hour of the server computing services , but the concern from MAS was that , is that computing service secure enough to protect the depositors information.
The Amazon speaker has given the big picture on how many firms are converting from traditional IT infrastructure set up to cloud computing services and more interesting was there were some of US government agencies started using cloud computing as their primary computing source of IT infrastructure. This clearly shows that cloud computing service has the required security controls in place.
I think the real big gap between the above two groups is the way they look at the security concerns prevailing over cloud computing. Once , this gap is clearly understood and perceived by both the groups , then only can the real era of cloud computing will start in the world of banking.
First one was from MAS (Monetary Authority of Singapore) at SMU and second was from Amazon web services the largest provider of cloud computing services. Each of them have totally opposite opinion on cloud computing.
To tell you some thing about cloud computing in one sentence , it a computing service exposed to public over internet. That means , you have to pay for the usage of service and only pay as much as you use the service. Just like your utility bill. As in the case of utilities like water and electricity , the user are unaware of how the drinking water , from where did the drinking water come from , similar is the case with Cloud Computing , the user will be unaware of how is the underlying IT infrastructure scaled , or where is the IT infrastructure available , they just use the service and pay for it.
The MAS speaker was concerned about the banks to expose their data on a public cloud. Banks can save a lot of money , if they are able to minimize the cost of their operations. When they start to use the cloud , they can pay as less as 5 USD per hour of the server computing services , but the concern from MAS was that , is that computing service secure enough to protect the depositors information.
The Amazon speaker has given the big picture on how many firms are converting from traditional IT infrastructure set up to cloud computing services and more interesting was there were some of US government agencies started using cloud computing as their primary computing source of IT infrastructure. This clearly shows that cloud computing service has the required security controls in place.
I think the real big gap between the above two groups is the way they look at the security concerns prevailing over cloud computing. Once , this gap is clearly understood and perceived by both the groups , then only can the real era of cloud computing will start in the world of banking.
Subscribe to:
Posts (Atom)