Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C++ help with some programming homework can you please help THANK YOU!! #include

ID: 646023 • Letter: C

Question

C++ help with some programming homework can you please help THANK YOU!!

#include <iostream>
#include <string>
using namespace std;

// Add an overloaded << operator to this class to print the student record
// in the following format (no newline at the end).
// (In this example, the student is "John Doe" with a netID of jdoe123:

// Doe, John (jdoe13)

class Student
{
private:
string last;
string first;
string netID;

public:
// Constructor
Student(const string lastName, const string firstName, const string ID);

// Here is the prototype for the overloaded << operator
friend ostream& operator<<(ostream& out, Student& s);
};

Student::Student(const string lastName, const string firstName,
const string ID)
{
last = lastName;
first = firstName;
netID = ID;
}

////////////// IMPLEMENT operator<< HERE ///////////////////

////////////////////////////////////////////////////////////

int main(int argc, char* argv[])
{
// Here's the example student
Student jd("Doe", "John", "jdoe123");

// And here's how it's output
cout << jd << endl;

return 0;
}

Explanation / Answer

#include <iostream>
#include <string>
using namespace std;

// Add an overloaded << operator to this class to print the student record
// in the following format (no newline at the end).
// (In this example, the student is "John Doe" with a netID of jdoe123:

//   Doe, John (jdoe13)

class Student
{
    private:
    string last;
    string first;
    string netID;

    public:
    // Constructor
    Student(const string lastName, const string firstName, const string ID);

    // Here is the prototype for the overloaded << operator
    friend ostream& operator<<(ostream& out, Student& s);
};

Student::Student(const string lastName, const string firstName,
                 const string ID)
{
    last = lastName;
    first = firstName;
    netID = ID;
}

////////////// IMPLEMENT operator<< HERE ///////////////////
ostream &operator<<(ostream& out, Student& s){
   out << s.last << ", " << s.first << " (" << s.netID << ")" << endl;
   return out;
}
////////////////////////////////////////////////////////////

int main(int argc, char* argv[])
{
    // Here's the example student
    Student jd("Doe", "John", "jdoe123");

    // And here's how it's output
    cout << jd << endl;

    return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote