You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
387 B
36 lines
387 B
3 years ago
|
#include <iostream>
|
||
|
|
||
|
class Test
|
||
|
{
|
||
|
private:
|
||
|
int _a;
|
||
|
int& _b = _a;
|
||
|
|
||
|
public:
|
||
|
Test()
|
||
|
{
|
||
|
_a = 5;
|
||
|
std::cout << "Normal constructor" << std::endl;
|
||
|
}
|
||
|
|
||
|
void printValue()
|
||
|
{
|
||
|
_b = 12;
|
||
|
std::cout << _a << "---" << _b << std::endl;
|
||
|
}
|
||
|
|
||
|
void printAddress()
|
||
|
{
|
||
|
std::cout << &_a << "---" << &_b << std::endl;
|
||
|
}
|
||
|
};
|
||
|
|
||
|
int main()
|
||
|
{
|
||
|
Test t;
|
||
|
t.printValue();
|
||
|
t.printAddress();
|
||
|
|
||
|
return 0;
|
||
|
}
|