I have created class ”A” with simple constructor that is printing a simple message on the screen:
A.hpp:
class A {
public:
A();
};
A.cpp:
#include "A.hpp"
#include <iostream>
A::A() {
std::cout << "From the class A." << std::endl;
}
and the second class ”B” that inherits from ”A”:
B.hpp:
#include "A.hpp"
class B : public A{
public:
B();
};
B.cpp
#include "B.hpp"
#include <iostream>
B::B() {
std::cout << "From the class B." << std::endl;
}
when i try to create instance of the class ”B”, i have the output:
From the class A.
From the class B.
So, how can i override the constructor to make it print just From the class B.
?