class A
{
        public:
                int a;
                A() : a(100) { }
               
};

class B : public A
{
        public:
                int b;
                B() : b(200){ }
};

int main()
{
        A a;
        B *ptrB =(B*)&a;

        cout<<ptrB->b<<endl; // Is there a way to get this to print 200??
}

the pointer is pointing to an object of class A which has no relation with class B...
using base class object cannot print value of b.

First use code tags. Your code is not formatted.Formatting makes your code easier to read.

class A
{
public:
     int a;
     A() : a(100) { }
};

class B : public A
{
public:
    int b;
     B() : b(200){ }
};

int main()
{
    A a; (B*)&a;

    cout << ptrB -> b << endl; // Is there a way to get this to print 200??
}

OK. Thanks for the info. Will have it in mind for future posts.