typedef int my_type;
const int ci = 10;
typedef double my_type;
const int ci = 20;
extern const int ci = 10;
extern const int ci;
int i = 4;
i = 5;
const int ci = 6;
ci = 7;
int *ip;
ip = &i;
*ip = 5;
ip = &ci;
*ip = 7;
ip = &ci;
const int *cip = &ci;
*cip = 7;
ip = cip;
cip = ip;
*cip = 5;
int const *icp;
icp = &i;
*icp = 5;
int * const ipc = &i;
*ipc = 5;
int * const ipc2 = &ci;
const int * const cccp = &ci;
class Date
{
public:
Date( int year = 2000, int month = 1, int day = 1);
int getYear();
int getMonth();
int getDay();
void set(int y, int m, int d);
private:
int year;
int month;
int day;
};
const Date my_birthday(1963,11,11);
Date other_date;
my_birthday = other_date;
my_birthday.set(1976,11,11);
int year = my_birthday.getYear();
class Date
{
public:
Date( int year = 2000, int month = 1, int day = 1);
int getYear() const;
int getMonth() const;
int getDay() const;
void set(int y, int m, int d);
private:
int year;
int month;
int day;
};
my_birthday.set(1976,11,11);
int year = my_birthday.getYear();
class Msg
{
public:
Msg(const char *t);
int getId();
private:
const int id;
std::string txt;
};
Msg m1("first"), m2("second");
m1.getId() != m2.getId();
MSg::Msg(const char *t)
{
txt = t;
id = getNextId();
}
MSg::Msg(const char *t) : id(getNextId()), txt(t)
{
}
struct Point
{
public:
void getXY(int& x, int& y) const;
private:
double xcoord;
double ycoord;
int n_read;
};
void Point::getXY(int& x, int& y) const
{
x = xcoord;
y = ycoord;
++n_read;
}
struct Point
{
public:
void getXY(int& x, int& y) const;
private:
double xcoord;
double ycoord;
mutable int n_read;
};
struct Point
{
public:
void getXY(int& x, int& y) const;
private:
double xcoord;
double ycoord;
mutable std::mutex m;
};
void Point::getXY(int& x, int& y) const
{
std::lock_guard<std::mutex> lock(m);
x = xcoord;
y = ycoord;
}
class X
{
static const int c1 = 7;
static int i2 = 8;
const int c3 = 9;
static const int c4 = f(2);
static const float f = 3.14;
};
const int X::c1;