vendredi 27 janvier 2017

How can I add to this code so it prints "b" without removing anything?

my question is : I have this code written in c++11 :

    #include <iostream>
    #include <string>

    using namespace std;
    class A{
    public:
    void print() const {cout << "a" << endl ;}
    };

    void f(const A& a){
    a.print();
    }

and I want to edit this code by adding to it but not removing anything, so it would print the letter "b" instead of "a" no matter the input. How is that possible? I haven't found an answer on the internet ?

Thanks in advance.

Aucun commentaire:

Enregistrer un commentaire