Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class Animal {
- private:
- const int age;
- string name;
- int *carne;
- public:
- Animal(const int& age, const string& name) : age(age), name(name) {
- carne = new int(10);
- cout << "io's constructor";
- }
- virtual ~Animal() {
- cout << "io's destructor";
- delete carne;
- }
- };
- int p = 9;
- void thisWillChangeTheValue(const int& a) {
- p = a;
- }
- void thisWillNOTChangeTheValue(int a) {
- int tempA = a;
- tempA = 10;
- }
- void thisWillChangeTheValueC(int* a) {
- *a = 6;
- }
- int main() {
- // int a = 50;
- //
- // cout << &a << " " << a << endl;
- //
- //
- // int* ptoa;
- // ptoa = &a;
- // *ptoa = 1000;
- //
- // cout << &a << " " << a << endl;
- //
- // cout << ptoa << " " << *ptoa << endl;
- //
- // thisWillChangeTheValueC(ptoa);
- //
- // cout << ptoa << " " << *ptoa << endl;
- //
- // int age = 10;
- // string name = "anal";
- //
- // Animal anim = Animal(age, name);
- //
- int a = 5;
- cout << a << endl;
- thisWillChangeTheValueC(&a);
- cout << a << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement