Ad
  • Custom User Avatar

    Your solution does the same you just take up another line to copy the contents of the initial string into a new one.

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar
  • Custom User Avatar

    You change initial condition

    • from: std::string DNAStrand(const std::string& dna)
    • to: std::string DNAStrand(std::string dna)

    Thus you made two copies of string, first - when signature passed, second - when return value

    #include <iostream>
    
    class AAA 
    {
    public:
        AAA ( ) {}
        
        AAA ( const AAA& other )
        {
            std::cout << "copy" << std::endl;
        }
    } ;
    
    AAA func ( AAA a )
    {
        return a;
    }
    
    int main()
    {
        AAA _a;
        AAA _b = func(_a);
    }
    
    Output is:
    copy
    copy
    

    Therefore it is a BAD practices ...