hello,
OK i need a little help,
i want to override a funtion from a parent class, but i can seem to get it to work,
so i have a layout the same as below, i want to override the Z function from class A in class B.
when i use this layout below it still calls the Z function from A rather than B, i am creating the object from B so from my understanding it should be overwrote...
can anyone help me out with this?
thanks
Philly
Class A Header:
Code:
#pragma once
class A
{
private:
void Y();
protected:
virtual void Z();
};
class A Source:
Code:
#include "stdafx.h"
#include "A.h"
void A::Y()
{
this->Z();
}
void A::Z()
{
// want to override this in class B;
}
Class B Header
Code:
#pragma once
#include "A.h"
class B : A
{
protected:
void Z();
};
Class B Source:
Code:
#include "stdafx.h"
#include "B.h"
void B::Z()
{
// Do Somthing Here!
}