1. What is reflective programming?
Answer: Reflective programming is the ability of a program to inspect and/or modify its own
structure and behaviour at runtime. In Qt/C++, the meta-object system provides facilities such as
properties, signals, slots and runtime type information.
2. What is a pure virtual function in C++?
Answer: A pure virtual function is declared using = 0, for example:
virtual void draw() = 0;
A class containing a pure virtual function becomes an abstract class and normally cannot be
instantiated directly.
3. What is inheritance?
Answer: Inheritance allows a derived class to acquire and extend properties and behaviour from
a base class.
4. What is polymorphism?
Answer: Polymorphism allows the same interface to represent different underlying
implementations. With virtual functions, a base-class pointer/reference can invoke the
appropriate derived-class implementation at runtime.
5. What is the purpose of a virtual destructor?
Answer: It ensures that when an object of a derived class is deleted through a base-class pointer,
the derived-class destructor is also called.
class Shape {
public:
virtual ~Shape() {}
};
6. What is the Singleton design pattern?
Answer: Singleton restricts a class to one instance and provides a controlled way of accessing
that instance.
Typical Qt/C++ structure:
class Logger {
private:
Logger() {}
public:
static Logger& getInstance() {
static Logger instance;
return instance;
}
};