diff options
author | Matt Kline <slavik262@gmail.com> | 2014-10-12 23:35:49 -0700 |
---|---|---|
committer | Matt Kline <slavik262@gmail.com> | 2014-10-12 23:37:10 -0700 |
commit | 8e9d5af1ea5680bbf5f232d5510f35f3c69619c2 (patch) | |
tree | e626eaecd6f2a4d29214b48b3638125fd3f6d082 /c++.html.markdown | |
parent | e1ed5393fc5f44473fbb0acb40ff8a902bcdf1c1 (diff) |
Minor C++ fixes
Diffstat (limited to 'c++.html.markdown')
-rw-r--r-- | c++.html.markdown | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/c++.html.markdown b/c++.html.markdown index ce2d2d65..b55a764c 100644 --- a/c++.html.markdown +++ b/c++.html.markdown @@ -150,7 +150,7 @@ int main() #include <iostream> // Include for I/O streams -using namespace std; +using namespace std; // Streams are in the std namespace (standard library) int main() { @@ -175,7 +175,7 @@ int main() // Strings in C++ are objects and have many member functions #include <string> -using namespace std; // Strings are in the namespace std (standard library) +using namespace std; // Strings are also in the namespace std (standard library) string myString = "Hello"; string myOtherString = " World"; @@ -210,7 +210,7 @@ string bar = "I am bar"; string& fooRef = foo; // This creates a reference to foo. fooRef += ". Hi!"; // Modifies foo through the reference -cout << foo; // Prints "I am foo. Hi!" +cout << fooRef; // Prints "I am foo. Hi!" fooRef = bar; // Error: references cannot be reassigned. @@ -373,6 +373,9 @@ public: // Overload the += operator Point& operator+=(const Point& rhs); + + // It would also make sense to add the - and -= operators, + // but we will skip those for brevity. }; Point Point::operator+(const Point& rhs) const |