there are 2 problems:
===someInt is not in Example class===
you have an Example class pointer.
Example class doesn't have someInt.
===possible problem===
AnotherClass has someInt but it looks like it's private. i'm guessing you accidentally removed the "public:" keyword. all class members are private by default. (because you can't even construct AnotherClass with the constructor private).
===possible solution===
usually people write "getter" and "setter" functions to access private variables (and keep them private). what you can do, is make a virtual function in the parent class (ExampleClass). then override it in the child class (AnotherClass) by simply defining it
---code---
class ExampleClass
{
//what ever definitions
public:
virtual void setSomeInt(int value) = 0; // pure virtual function
}
Class AnotherClass : public ExampleClass
{
private:
int someInt;
public: // this should have been here
AnotherClass()
{
someInt = 1;//just a random value
}
void setSomeInt(int value)
{
someInt = value;
}
}
ExampleClass *examplePointer = new AnotherClass();
examplePointer->setSomeInt(2); // use the setter function
----------
now any class that inherits from ExampleClass has to override the virtual function "setSomeInt" with it's own implementation/behavior.
ExampleClass does not have it's own implementation of "setSomeInt", so it's pure virtual. this is indicated by "= 0;".
so you can only create an instance of ExampleClass by creating an instance of it's child class (AnotherClass) like you did with "ExampleClass *examplePointer = new AnotherClass();", because ExampleClass incomplete (an abstract class).
if you want to be able create an instance of ExampleClass directly. you need to provide a default implementation for the virtual function in ExampleClass, like:
---code---
virtual void setSomeInt(int value) // do nothing ("= 0;" has simply been replaced with {})
{
}
----------
===additional details===
you need to create a getter "int getSomeInt()" function for which you need to do the same. then you will be able to read the value as well:
---code---
if (examplePointer->isAnotherClass())
{
std::cout << examplePointer->getSomeInt(); // use the getter
}
----------