#include <cstring>
namespace DataStructures
{
template <typename T>
class DynamicArray
{
public:
DynamicArray(int size, T initValue)
: mSize(size),
mData(new T[mSize]);
{
for (int i = 0; i < mSize; ++i)
{
mData[i] = initValue;
}
}
private:
size_t mSize;
T *mData;
};
}// Avoid.
int a, b, area_of_rectangle;
char *c, *d;
// Prefer.
int height;
int width;
char *name = nullptr;
char *title = nullptr;
int areaOfRectangle = height * width;/* Avoid. Might fail because static initialization order is undefined. */
Database db;
QueryProcessor qp(db);
/* If inevitable and available. Guarantees thread-safe initialization on first use. */
Q_GLOBAL_STATIC(Database, gDb);
Q_GLOBAL_STATIC_WITH_ARGS(QueryProcessor, gQp, gDb);
// Avoid.
const string gStrAppName = "Code Convention";
// Prefer.
const char gCharAppName[] = "Code Convention";
int main()
{
// Avoid.
int h, w, area;
h = 10;
w = 10;
a = h * w;
// Prefer.
int height = 10;
int width = 10;
int area = height * width;
return 0;
}