Skip to content

Use C++11 (or 14) features by default #122

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/compilation.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ <h2 id="help-my-code-doesnt-compile">Help! My code doesn't compile!</h2>
<li>Check the section, below, on common compiler errors and how to solve them, as the error that you are looking for may be listed there</li>
<li>Did you submit all the required files? In particular, if some of the files that you <code>#include</code> are not present, then it won't compile.</li>
<li>Filename case: Linux (what the compilation is done on) does care about the capitalization of file names. So if your code has an <code>#include &quot;FileName.h&quot;</code> and your file is named filename.h, this will NOT compile under Linux. Change your file name cases, or your <code>#include</code> line.</li>
<li>Did you include the appropriate system <code>#include</code> lines? If it is complaining that it can't find <code>exit()</code>, for example, be sure to <code>#include &lt;stdlib.h&gt;</code>. Many compilers automatically include <code>&lt;stdlib.h&gt;</code> and <code>&lt;stdio.h&gt;</code>, which means you can directly call functions such as <code>printf()</code> and <code>exit()</code> without the appropriate <code>#include</code> line. The compiler used by the submission system does not include, by default, any <code>#include</code> files.</li>
<li>Did you include the appropriate system <code>#include</code> lines? If it is complaining that it can't find <code>find()</code>, for example, be sure to <code>#include &lt;algorithm&gt;</code>.</li>
<li>Did you enter <code>using namespace std;</code> at the top of each file?</li>
<li>The submission system provides the compilation command - try running it on your machine. In particular, try creating a NEW directory, copying into that directory the files that you are submitting (and ONLY those files), and then executing the compile command.</li>
<li>If the compile command is <code>make</code> (you learn about make and Makefiles about 1/3 of the way through the course), then your Makefile needs to be configured to properly compile the code</li>
Expand Down
2 changes: 1 addition & 1 deletion docs/compilation.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ There are a number of things you can try:
- Check the section, below, on common compiler errors and how to solve them, as the error that you are looking for may be listed there
- Did you submit all the required files? In particular, if some of the files that you `#include` are not present, then it won't compile.
- Filename case: Linux (what the compilation is done on) does care about the capitalization of file names. So if your code has an `#include "FileName.h"` and your file is named filename.h, this will NOT compile under Linux. Change your file name cases, or your `#include` line.
- Did you include the appropriate system `#include` lines? If it is complaining that it can't find `exit()`, for example, be sure to `#include <stdlib.h>`. Many compilers automatically include `<stdlib.h>` and `<stdio.h>`, which means you can directly call functions such as `printf()` and `exit()` without the appropriate `#include` line. The compiler used by the submission system does not include, by default, any `#include` files.
- Did you include the appropriate system `#include` lines? If it is complaining that it can't find `find()`, for example, be sure to `#include <algorithm>`.
- Did you enter `using namespace std;` at the top of each file?
- The submission system provides the compilation command - try running it on your machine. In particular, try creating a NEW directory, copying into that directory the files that you are submitting (and ONLY those files), and then executing the compile command.
- If the compile command is `make` (you learn about make and Makefiles about 1/3 of the way through the course), then your Makefile needs to be configured to properly compile the code
Expand Down
77 changes: 38 additions & 39 deletions labs/lab01/list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
// 01-13-14: Modified to fit modern C++ compilers; reformatted

#include <iostream>
#include <stdio.h>
#include "list.h"

using namespace std;
Expand All @@ -24,14 +23,14 @@ int main() {
cout << "size(): returned " << l->size() << endl;

n = l->head();
if ( n == NULL )
cout << "head(): returned NULL." << endl;
if ( n == nullptr )
cout << "head(): returned nullptr." << endl;
else
cout << "head(): returned " << *n << endl;

n = l->tail();
if ( n == NULL )
cout << "tail(): returned NULL." << endl;
if ( n == nullptr )
cout << "tail(): returned nullptr." << endl;
else
cout << "tail(): returned " << *n << endl;

Expand All @@ -44,29 +43,29 @@ int main() {
cout << "empty() called, returned " << l->empty() << endl;

n = l->head();
if ( n == NULL )
cout << "head(): returned NULL." << endl;
if ( n == nullptr )
cout << "head(): returned nullptr." << endl;
else
cout << "head(): returned " << *n << endl;

n = l->tail();
if ( n == NULL )
cout << "tail(): returned NULL." << endl;
if ( n == nullptr )
cout << "tail(): returned nullptr." << endl;
else
cout << "tail(): returned " << *n << endl;

l->push(3);
l->display();

n = l->head();
if ( n == NULL )
cout << "head(): returned NULL." << endl;
if ( n == nullptr )
cout << "head(): returned nullptr." << endl;
else
cout << "head(): returned " << *n << endl;

n = l->tail();
if ( n == NULL )
cout << "tail(): returned NULL." << endl;
if ( n == nullptr )
cout << "tail(): returned nullptr." << endl;
else
cout << "tail(): returned " << *n << endl;

Expand All @@ -81,29 +80,29 @@ int main() {
l->display();

n = l->head();
if ( n == NULL )
cout << "head(): returned NULL." << endl;
if ( n == nullptr )
cout << "head(): returned nullptr." << endl;
else
cout << "head(): returned " << *n << endl;

n = l->tail();
if ( n == NULL )
cout << "tail(): returned NULL." << endl;
if ( n == nullptr )
cout << "tail(): returned nullptr." << endl;
else
cout << "tail(): returned " << *n << endl;

l->push(5);
l->display();

n = l->head();
if ( n == NULL )
cout << "head(): returned NULL." << endl;
if ( n == nullptr )
cout << "head(): returned nullptr." << endl;
else
cout << "head(): returned " << *n << endl;

n = l->tail();
if ( n == NULL )
cout << "tail(): returned NULL." << endl;
if ( n == nullptr )
cout << "tail(): returned nullptr." << endl;
else
cout << "tail(): returned " << *n << endl;

Expand All @@ -112,54 +111,54 @@ int main() {
cout << endl;

n = l->pop();
if ( n == NULL )
cout << "pop(): list is empty, pop(): returned NULL." << endl;
if ( n == nullptr )
cout << "pop(): list is empty, pop(): returned nullptr." << endl;
else
cout << "pop(): returned " << *n << endl;

l->display();

n = l->head();
if ( n == NULL )
cout << "head(): returned NULL." << endl;
if ( n == nullptr )
cout << "head(): returned nullptr." << endl;
else
cout << "head(): returned " << *n << endl;

n = l->tail();
if ( n == NULL )
cout << "tail(): returned NULL." << endl;
if ( n == nullptr )
cout << "tail(): returned nullptr." << endl;
else
cout << "tail(): returned " << *n << endl;

cout << "size(): returned " << l->size() << endl;

n = l->pop();
if ( n == NULL )
cout << "pop(): list is empty, pop(): returned NULL." << endl;
if ( n == nullptr )
cout << "pop(): list is empty, pop(): returned nullptr." << endl;
else
cout << "pop(): returned " << *n << endl;

l->display();

n = l->pop();
if ( n == NULL )
cout << "pop(): list is empty, pop(): returned NULL." << endl;
if ( n == nullptr )
cout << "pop(): list is empty, pop(): returned nullptr." << endl;
else
cout << "pop(): returned " << *n << endl;

l->display();

n = l->pop();
if ( n == NULL )
cout << "pop(): list is empty, pop(): returned NULL." << endl;
if ( n == nullptr )
cout << "pop(): list is empty, pop(): returned nullptr." << endl;
else
cout << "pop(): returned " << *n << endl;

l->display();

n = l->pop();
if ( n == NULL )
cout << "pop(): list is empty, pop(): returned NULL." << endl;
if ( n == nullptr )
cout << "pop(): list is empty, pop(): returned nullptr." << endl;
else
cout << "pop(): returned " << *n << endl;

Expand All @@ -182,16 +181,16 @@ int main() {
l->display();

n = l->pop();
if ( n == NULL )
cout << "pop(): list is empty, pop(): returned NULL." << endl;
if ( n == nullptr )
cout << "pop(): list is empty, pop(): returned nullptr." << endl;
else
cout << "pop(): returned " << *n << endl;

l->display();

n = l->pop_head();
if ( n == NULL )
cout << "pop_head(): list is empty, pop_head(): returned NULL." << endl;
if ( n == nullptr )
cout << "pop_head(): list is empty, pop_head(): returned nullptr." << endl;
else
cout << "pop_head(): returned " << *n << endl;

Expand Down
Loading