Demo entry 6777358

class Animal { int age; }; class Dog : public Animal { int color; }; int main() { Dog d; Dog* p1 = &d; // ok. double* p2 = &d; // error. Animal* p3 = &d; // ok. }

   

Submitted by anonymous on Dec 10, 2018 at 06:22
Language: C++. Code size: 208 Bytes.

class Animal
{
    int age;
};
class Dog : public Animal
{
    int color;
};

int main()
{
    Dog d;
    Dog*    p1 = &d;  // ok.
    double* p2 = &d;  // error.
    Animal* p3 = &d;  // ok.
}

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).