• + 0 comments

    Ussing operator overloading for fun, we all know it is not necessary.

    string operator*(const std::string& str, int count){
        std::string result = "";
        for (int i = 0; i < count; ++i) {
            result += str;
        }
        return result;
    }
    
    string operator*(int count, const string& str) {
        return str * count;
    }
    
    void staircase(int n) {
        int steps = n;
        while (n-->0) {
            cout<<" "s*n + "#"s*(steps-n)<<endl;
        }
    }