Throughout the entries, I missed the support for "const std::string" and the prevention of 'evil' or pointless code.
const string s = "12345";
cout << Mid(s,1,2);
Mid("12345",1,2) = "abc";
Here are the results:
===================
=Sebastian McKelvy=
===================
Fidelity 0/10
--------
Basic test incorrect : 234
First test incorrect : 123
Second test incorrect : 123
Third test incorrect : abc
I also had to comment away these lines in my test code:
//s2 = Mid("0123456789",1,4);
//Mid(s1, 1, 1) = Mid(s4,1);
Efficiency 0/10
----------
The code is very short, but doesn't do much right
Elegance 1/5
--------
No commenting
The solution is not very elegant.
Portability 5/5
-----------
No problems
-== TOTAL: 6 ==-
==================
=Travis Dane=
==================
Fidelity 1/10
--------
Didn't provide a function, which was required.
Didn't understand what Mid()=Mid() should do.
Basic functionality doesn't work, the program outputs "hel " instead
of "hel"
He has an operator= though.
Efficiency 2/10
----------
Short and simple code, but lacking functionality.
Elegance 2/5
--------
Nice commenting
Not very good solution with the (non-static) function inside the class
Portability 4.5/5
-----------
He used conio.h, but only in the main() function.
-== TOTAL: 9.5 ==-
==============
=Dorian Boyce=
==============
Fidelity 7/10
--------
Doesn't work with C-strings:
s2 = Mid("0123456789",1,4);
Unable to handle constant strings
Efficiency 8/10
----------
Could've used member functions instead of for-loops in the = operator No member initialization list Manual copying of the string in operator= instead of non-reference argument
Elegance 2/5
--------
Constructor is public
No private copy-constructor (to prevent use outside the Mid() function) No commenting
Good solution
Portability 5/5
-----------
No problems
-== TOTAL: 23 ==-
===============
= CodePlug =
===============
Fidelity 8/10
--------
Compiled and succeeded all tests (on MS VC++.NET only -- see
portability) Great!
No support for const std::string though
Evil code did compile.
Efficiency 10/10
----------
Very short code!
Elegance 3/5
--------
Well commented!
C-style pointer casts
Global variables
Constructor is public (btw, why didn't he call the class Mid to get rid of the redundant functions?)
Portability 3/5
-----------
Code is not standard -- problem with reference class members when copying Doesn't compile with CodeWarrior Doesn't compile with Comeau C++ -- The absolutely best compiler when it comes to standard compliance.
http://www.comeaucomputing.com/tryitout/
-== TOTAL: 24 ==-
======
=DavT=
======
Fidelity 8/10
--------
Compiled and succeeded all tests (on MS VC++.NET only -- see
portability) Great!
No support for const std::string though
Evil code did compile.
Efficiency 9/10
----------
Short code!
Elegance 4/5
--------
Well commented!
C-style pointer casts (unnecessary, too)
Portability 3/5
-----------
Code is not standard -- problem with reference class members when copying Doesn't compile with CodeWarrior Doesn't compile with Comeau C++ -- The absolutely best compiler when it comes to standard compliance.
http://www.comeaucomputing.com/tryitout/
-== TOTAL: 24 ==-