Another code problems
#include <iostream> #include <vector> using namespace std; //number you inputed class Number{ public: int setNumber(){ cin >> num; } int getNumber(){ return num; } friend void infoStreamerN(Number *obj); protected: int num; }; //number in cube class CubeNumber : public Number{ public: int getCubeNumber (){ return cNum; } friend void infoStreamerCn(CubeNumber *obj1); private: int cNum = num*num*num; }; //outputs information void infoStreamer(Number *obj){ cout << "Your input: " << obj->getNumber() << "\n"; delete obj; } void infoStreamerCn(CubeNumber *obj1){ cout << obj1->getNumber() << "^3 = " << obj1->getCubeNumber(); } int main() { Number *n = new Number; CubeNumber *cn = new CubeNumber; n->setNumber(); infoStreamer(n); infoStreamerCn(cn); return 0; } Outputs 63838282 but it isn't an inputed number. Am i overloading memory somewhere or pointing into wrong space? Write your answers.