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

I\'m having a problem with my code and would like some help with it. This is my

ID: 3803132 • Letter: I

Question

I'm having a problem with my code and would like some help with it.

This is my code:

#include <iostream>
using namespace std;

class Table {
public:
void SetSeatA( int personA );
void SetSeatB( int personB );
int GetSeatA();
int GetSeatB();
void SwapSeats();

private:
int seatA;
int seatB;
};

int main(){
Table t;
int person;
cin >> person;
t.SetSeatA(person);
cin >> person;
t.SetSeatB(person);

t.SwapSeats();
cout << "Seat A = " << t.GetSeatA() << endl;
cout << "Seat B = " << t.GetSeatB() << endl;

return;
}

When I run my code I get this error:

main.cpp: In function 'int main()': main.cpp:29:4: error: return-statement with no value, in function returning 'int' [-fpermissive] return;

7.22 Day 20: Swapping w/ Private Data Students This content is controlled by your instructor, and is not zyBooks content. Direct questions or concerns about this content to your instructor. If you have any technical issues with the zyLab submission system, use the "Trouble with lab?" button at the bottom of the lab. swapping Seats w/ Private Data Create public members to access private members. We'll do this activity in class

Explanation / Answer

Errors:

I'm providing you the modified code try to run as I'm running it in GNU plugin in DEV-C++ & the programme runs fine.

#include <iostream>
using namespace std;
class Table {
private:
int seatA;
int seatB;
public:
void SetSeatA(int personA){
    seatA = personA;
   }
void SetSeatB(int personB){
    seatB = personB;
   }
int GetSeatA(){
    return seatA;
   }
int GetSeatB(){
    return seatB;
   }
void SwapSeats(){
    int temp = seatA;
    seatA = seatB;
    seatB = temp;
   }

};
int main(){
Table t;
int person;
cin >> person;
t.SetSeatA(person);
cin >> person;
t.SetSeatB(person);

t.SwapSeats();
cout << "Seat A = " << t.GetSeatA() << endl;
cout << "Seat B = " << t.GetSeatB() << 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