I've a Class called Layout which is the parent class of MyLayout
e.g. MyLayout extends Layout.
Now another Class App takes Layout& argument on one of its constructor.
App Class have a member variable called layout on which an instance of Layout Class exists.
which is meant to be optionally instantiable from constructor.
App Class have an exec() method that calls layout.fnc()
Layout's fnc() is virtual

Now the problem is I should be able to do App app(MyLayout) as well as App(Layout)
as MyLayout is a Child class of Layout Class.

The Code is being Compiled if I pass a MyLayout Class in constructor's argument.
but It is calling Layout::fnc() instead of MyLayout::fnc()

-------------- All My codes are Attached ------------------

layout.h
Code:
#include <iostream>

using std::cout;
using std::endl;

class Layout{
	public:
    Layout();
    ~Layout();
	public:
		virtual void func();
};
layout.cpp
Code:
#include "layout.h"
Layout::Layout(){

}
Layout::~Layout(){

}
void Layout::func(){
	cout<<"Layout::func()"<<endl;
}
mylayout.h
Code:
#include "layout.h"

class MyLayout : public Layout{
	public:
    MyLayout();
    ~MyLayout();
	public:
    virtual void func();
};
mylayout.cpp
Code:
#include "mylayout.h"
MyLayout::MyLayout(): Layout(){

}
MyLayout::~MyLayout(){

}
void MyLayout::func(){
	cout<<"MyLayout::func()"<<endl;
}
app.h
Code:
#include "layout.h"

class App{
	public:
		Layout layout;
	public:
    App();
    App(Layout& lt);
    ~App();
    void exec();
};
app.cpp
Code:
App::App(){

}
App::App(Layout& lt):layout(lt){

}
App::~App(){

}
void App::exec(){
	layout.func();
}
main.cpp
Code:
#include "app.h"
#include "mylayout.h"

using namespace std;

int main(int argc, char *argv[]){
	MyLayout l;
	App a(l);
	a.exec();
  return EXIT_SUCCESS;
}