Compare commits
5 Commits
8b451ff045
...
ddba0c00d3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ddba0c00d3 | ||
|
|
c87d05085b | ||
|
|
8eba07df5d | ||
|
|
f4232e8c1b | ||
|
|
81b8266571 |
@@ -1,4 +1,4 @@
|
|||||||
# Lab 3 — Memory Diagrams, Testing, and Debugging
|
# Testing, and Debugging
|
||||||
|
|
||||||
For this lab, you must use a terminal. Do not use IDEs for this lab.
|
For this lab, you must use a terminal. Do not use IDEs for this lab.
|
||||||
|
|
||||||
@@ -136,7 +136,7 @@ figure out how to do each of the steps below in your debugger of choice.
|
|||||||
Note that in addition to a standard step-by-step program debugger like gdb/lldb, we also recommend the use
|
Note that in addition to a standard step-by-step program debugger like gdb/lldb, we also recommend the use
|
||||||
of a memory debugger (drmemory or valgrind) for programs with dynamically-allocated memory (we’ll soon talk about this in Lectures), or anytime you have a segmentation fault or other confusing program behavior. We’ll work the memory debugger in lab next week! Information about memory debuggers is
|
of a memory debugger (drmemory or valgrind) for programs with dynamically-allocated memory (we’ll soon talk about this in Lectures), or anytime you have a segmentation fault or other confusing program behavior. We’ll work the memory debugger in lab next week! Information about memory debuggers is
|
||||||
available here:
|
available here:
|
||||||
http://www.cs.rpi.edu/academics/courses/fall23/csci1200/memory_debugging.php
|
http://www.cs.rpi.edu/academics/courses/spring25/csci1200/memory_debugging.php
|
||||||
|
|
||||||
After today’s lab, you should be comfortable with the basics of command line debugging within your preferred
|
After today’s lab, you should be comfortable with the basics of command line debugging within your preferred
|
||||||
development environment. Keep practicing with the debugger on your future homeworks, and be prepared
|
development environment. Keep practicing with the debugger on your future homeworks, and be prepared
|
||||||
|
|||||||
@@ -170,20 +170,19 @@ ClassName& operator=(const ClassName& other);
|
|||||||
```cpp
|
```cpp
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
class MyClass {
|
class MyClass {
|
||||||
private:
|
private:
|
||||||
string name; // Using a standard string (no pointers)
|
std::string name;
|
||||||
public:
|
public:
|
||||||
MyClass(const string& initName) : name(initName) {}
|
MyClass(const std::string& initName) : name(initName) {}
|
||||||
|
|
||||||
MyClass& operator=(const MyClass& other) {
|
MyClass& operator=(const MyClass& other) {
|
||||||
name = other.name; // Copy data
|
name = other.name; // Copy data
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void print() const { cout << "Name: " << name << endl; }
|
void print() const { std::cout << "Name: " << name << std::endl; }
|
||||||
};
|
};
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
|||||||
@@ -22,8 +22,9 @@ else
|
|||||||
cout << "Smaller\n";
|
cout << "Smaller\n";
|
||||||
```
|
```
|
||||||
|
|
||||||
The output is Bigger
|
The output is ?
|
||||||
because x == 72.0. What’s going on?
|
<!-- Bigger
|
||||||
|
because x == 72.0. What’s going on?-->
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
@@ -198,7 +199,7 @@ for ( i=0; i<n; ++i ){
|
|||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
This second approach also "nicely mimics the subscript notation used in the (original) for loop above, which highlights that fundamentally array subscripts are just pointer arithmetic." - comments by our mentor Eleanor Olson, :smile:.
|
This second approach also "nicely mimics the subscript notation used in the (original) for loop above, which highlights that fundamentally array subscripts are just pointer arithmetic." - comments by a former mentor.
|
||||||
|
|
||||||
## 5.9 Sorting an Array
|
## 5.9 Sorting an Array
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user