Skip to content

Commit

Permalink
wrong code
Browse files Browse the repository at this point in the history
  • Loading branch information
Dobiasd committed Nov 17, 2013
1 parent f5073bd commit 64121a0
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions from_oop_to_fp_-_inheritance.md
Original file line number Diff line number Diff line change
Expand Up @@ -289,21 +289,17 @@ displayFoo (Foo intVal) = show intVal
```

```haskell
// Bar.h
#ifndef BAR_H
#define BAR_H
#include "Base.h"
class Bar : public Base
{
public:
Bar(const std::string& s) : strVal_(s) {}
// Concat delta as string to internal state.
virtual void step(int delta) { strVal_ += std::to_string(delta); }
virtual std::string display() { return strVal_; }
private:
std::string strVal_;
};
#endif
-- Bar.hs
module Bar where

import Base

-- Concat delta as string to internal state.
stepBar :: Base -> Int -> Base
stepBar (Bar strVal) delta = Bar $ strVal ++ show delta

displayBar :: Base -> String
displayBar (Bar strVal) = strVal
```

```haskell
Expand Down

0 comments on commit 64121a0

Please sign in to comment.