Question
All of this should be able to be done in a linux terminal. Overview: In this assignment, you will use make to modify a c++
All of this should be able to be done in a linux terminal.
Overview: In this assignment, you will
use make to modify a c++ program and
gdb a debugging tool.
Part 1 From the course website (or the departmental dropbox) download the program source files for the project myname. (provided below)
Part 2: myname program (5 points)
1. Using your favorite text editor, modify the source code to print out your name instead of mine when the binary file is executed. Hint: YOU ARE NOT THOMAS THE TANK ENGINE (make of comment of where you change this so I can change it to my name please)
2. Modify the makefile to include a rule that creates a backup of the source files, makefile, and readme in an archive directory in your home directory structure. Submit a compressed, archived tar file [yourUserID].assignment4_1.tar.[Z,gz] with your modified source code.
3. Use the gdb debugger to step through the program. Check to ensure the Makefile is modified to allow for debugging. Submit a text file [yourUserID].assignment4_2.txt containing the gdb output for the following sequence of commands:
gdb myname
start
step [issue this command until you get the program exited normally message]
quit
Source files:
makefile.cpp
# makefile to build a program # program depends on components: name and main myname: main.o name.o g++ -g main.o name.o -o myname # name.cpp has it's own header file name.o: name.cpp name.h g++ -c -g name.cpp # main.cpp also uses the header file name.h main.o: main.cpp name.h g++ -c -g main.cpp clean:
/bin/rm -f myname *.o
main.cpp
#include #include using namespace std; #include "name.h" int main () { name myName; myName.SetLast(LAST); myName.SetMiddle(MI); myName.SetFirst(FIRST); cout <<"My name is: "; myName.PrintFirst(); myName.PrintMiddle(); myName.PrintLast(); return 0; } |
name.cpp
#include #include using namespace std; #include "name.h" void name::GetFirst(string str) { str=first; } void name::SetFirst(string str) { first=str; } void name::GetMiddle(string str) { str=middle; } void name::SetMiddle(string str) { middle=str; } void name::GetLast(string str) { str=last; } void name::SetLast(string str) { last=str; } void name::PrintLast() { cout << last << " "; } void name::PrintMiddle() { cout << middle; } void name::PrintFirst() { cout << first; } |
name.h
#define LAST "grabasandwhich" #define MI "G." #define FIRST "bobby " class name { private: string first; string middle; string last; public: void SetFirst(string str); void GetFirst(string str); void SetMiddle(string str); void GetMiddle(string str); void SetLast(string str); void GetLast(string str); void PrintLast(); void PrintMiddle(); void PrintFirst(); }; |
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started