-I need help fixing these 7 errors Error 1 error C2065: \'name\' : undeclared id
ID: 653231 • Letter: #
Question
-I need help fixing these 7 errors
Error 1 error C2065: 'name' : undeclared identifier c:usersjesusdocumentsisual studio 2013projectsexam 1(revision and add on)exam 1(revision and add on)lab.cpp 45 1 Exam 1(revision and add on)
Error 2 error C2589: '<' : illegal token on right side of '::' c:usersjesusdocumentsisual studio 2013projectsexam 1(revision and add on)exam 1(revision and add on)lab.cpp 45 1 Exam 1(revision and add on)
Error 3 error C2059: syntax error : '::' c:usersjesusdocumentsisual studio 2013projectsexam 1(revision and add on)exam 1(revision and add on)lab.cpp 45 1 Exam 1(revision and add on)
7 IntelliSense: identifier "name" is undefined c:UsersjesusDocumentsVisual Studio 2013ProjectsExam 1(revision and add on)Exam 1(revision and add on)Lab.cpp 45 4 Exam 1(revision and add on)
8 IntelliSense: expected an identifier c:UsersjesusDocumentsVisual Studio 2013ProjectsExam 1(revision and add on)Exam 1(revision and add on)Lab.cpp 45 11 Exam 1(revision and add on)
9 IntelliSense: identifier "Lab" is undefined c:UsersjesusDocumentsVisual Studio 2013ProjectsExam 1(revision and add on)Exam 1(revision and add on)Lab.cpp 45 12 Exam 1(revision and add on)
10 IntelliSense: expected a ';' c:UsersjesusDocumentsVisual Studio 2013ProjectsExam 1(revision and add on)Exam 1(revision and add on)Lab.cpp 45 16 Exam 1(revision and add on)
Error 4 error C2065: 'overloaded' : undeclared identifier c:usersjesusdocumentsisual studio 2013projectsexam 1(revision and add on)exam 1(revision and add on)computerlab_exam.cpp 68 1 Exam 1(revision and add on)
Error 5 error C2146: syntax error : missing ';' before identifier 'cout' c:usersjesusdocumentsisual studio 2013projectsexam 1(revision and add on)exam 1(revision and add on)computerlab_exam.cpp 68 1 Exam 1(revision and add on)
Error 6 error C2059: syntax error : '/' c:usersjesusdocumentsisual studio 2013projectsexam 1(revision and add on)exam 1(revision and add on)computerlab_exam.cpp 197 1 Exam 1(revision and add on)
---------------------------------------------------------------------
//Interface File for Computer
//Header file Computer.h: This is the INTERFACE for the class Computer.
//This type models a computer in the Lab, and keep track of who is logged in
///////////////// 3 EXAM TASKS - a total of 20 points
#ifndef COMP_H
#define COMP_H
#include <iostream>
#include <string>
using namespace std;
namespace csc161
{
class Computer_T
{
public:
friend bool operator ==(const Computer_T& comp1, const Computer_T& comp2);
Computer_T();
Computer_T(string model);
Computer_T(const Computer_T& p_computer);
// Destructor
~Computer_T();
void set(string model);
string get_model() const;
void reboot();
void putOffline();
void putOnline();
bool isAvailable();
int whoIsLoggedIn();
void signon(int p_student_id);
void signoff();
friend istream& operator >>(istream& ins, Computer_T& the_object);
friend ostream& operator <<(ostream& outs, const Computer_T& the_object);
private:
string model;
bool online;
bool available;
int student_id;
};
typedef Computer_T* ComputerPtr;
}
#endif
------------------------------------------------------------------------------------------------------------------------
//Header file Lab.h
#ifndef LAB_H
#define LAB_H
#include <iostream>
#include <string>
namespace csc161
{
class Lab_T
{
public:
friend bool operator ==(const Lab_T& lab1, const Lab_T& lab2);
Lab_T();
Lab_T(std::string p_lab_name, unsigned int p_lab_size);
Lab_T(const Lab_T& p_lab);
~Lab_T();
std::string getLabName() const;
void setLabSize(std::string p_lab_name);
unsigned int getLabSize() const;
void setLabSize(unsigned int p_lab_size);
ComputerPtr getComputers();
friend ostream& operator <<(ostream& outs, const Lab_T& the_object);
private:
std::string lab_name;
int lab_size;
ComputerPtr computers;
};
typedef Lab_T* LabPtr;
}
#endif
--------------------------------------------------------------------------------
//Implementation File for Computer.cpp
//Header file is in Computer.h
#include <iostream>
#include <string>
#include "Computer.h"
using namespace std;
const int OPEN = -1;
namespace csc161
{
std::string Computer_T::get_model() const { return model; };
bool operator ==(const Computer_T& comp1, const Computer_T& comp2)
{
return
comp1.get_model() == comp2.get_model();
};
Computer_T::Computer_T(string p_model) {
model = p_model;
};
Computer_T::Computer_T(const Computer_T& p_computer)
{
ComputerPtr a = new Computer_T;
*a = p_computer;
};
Computer_T::Computer_T() {
model = "";
> available = true;
student_id = 0;
};
Computer_T::~Computer_T() {};
void Computer_T::reboot()
{
> available = true;
student_id = OPEN;
};
void Computer_T::putOffline() {
>
};
void Computer_T::putOnline() {
>
};
bool Computer_T::isAvailable() { return available; };
int Computer_T::whoIsLoggedIn() { return student_id; };
void Computer_T::signon(int p_student_id)
{
available = false;
student_id = p_student_id;
};
void Computer_T::signoff()
{
student_id = OPEN;
available = true;
};
istream& operator >>(istream& ins, Computer_T& the_object)
{
ins >> the_object.model;
return ins;
}
ostream& operator <<(ostream& outs, const Computer_T& the_object)
{
{
if (the_object.student_id == OPEN)
outs << "Open ";
else
outs << the_object.student_id;
return outs;
}
}
}
------------------------------------------------------------------------------------------------------------------------
#include <iostream>
#include <cstdlib>
#include <string>
using namespace std;
#include "Computer.h"
#include "Lab.h"
using namespace csc161;
const int NUMLABS = 4;
void createLabs(LabPtr cscLabs[], int labsizes[]);
void destroyLabs(LabPtr cscLabs[]);
void login(LabPtr cscLabs[], int labsizes[]);
void logoff(LabPtr cscLabs[], int labsizes[]);
void search(LabPtr cscLabs[], int labsizes[]);
void showLabs(LabPtr cscLabs[], int labsizes[]);
bool validID(int p_id)
{
return (p_id < 0 || p_id > 99999);
}
int enterID(int p_id)
{
cout << "Please enter your 6 digit ID." << endl;
validID(p_id);
return p_id;
}
void createLabs(LabPtr cscLabs[], string labNames[], int labSizes[])
{
for (int i = 0; i < NUMLABS; i++)
{
cscLabs[i] = new Lab_T(labNames[i], labSizes[i]);
}
return;
}
void destroyLabs(LabPtr cscLabs[])
{
int i;
for (i = 0; i < NUMLABS; i++)
{
delete cscLabs[i];
}
return;
}
void showLabs(LabPtr cscLabs[], int labsizes[])
{
int i, j;
cout << "LAB STATUS" << endl;
cout << "Lab # Computer Stations" << endl;
for (i = 0; i < NUMLABS; i++)
{
cout << i + 1 << " ";
for (j = 0; j < labsizes[i]; j++)
{
cout << (j + 1) << ": ";
/**
if ((((cscLabs[i])->getComputers())[j]).isAvailable())
{
cout << "Open ";
}
else
{
cout << cscLabs[i]->getComputers()[j].whoIsLoggedIn() << " ";
}
**/
overloaded
cout << cscLabs[i]->getComputers()[j];
}
cout << endl;
}
cout << endl;
return;
}
void login(LabPtr cscLabs[], int labsizes[])
{
int id = -1, lab = -1, num = -1;
while ((id < 0) || (id > 99999))
{
cout << "Enter the 5 digit ID number of the user logging in:" << endl;
cin >> id;
}
while ((lab < 0) || (lab > NUMLABS))
{
cout << "Enter the lab number the user is logging in from (1-" <<
NUMLABS << "):" << endl;
cin >> lab;
}
while ((num < 0) || (num > labsizes[lab - 1]))
{
cout << "Enter computer station number the user is logging in to " <<
"(1-" << labsizes[lab - 1] << "):" << endl;
cin >> num;
}
if (!cscLabs[lab - 1]->getComputers()[num - 1].isAvailable())
{
cout << "ERROR, user " << cscLabs[lab - 1]->getComputers()[num - 1].whoIsLoggedIn() <<
" is already logged into that station." << endl;
return;
}
cscLabs[lab - 1]->getComputers()[num - 1].signon(id);
return;
}
void logoff(LabPtr cscLabs[], int labsizes[])
{
int id = -1, i, j;
while ((id < 0) || (id > 99999))
{
cout << "Enter the 5 digit ID number of the user to find:" << endl;
cin >> id;
}
for (i = 0; i<NUMLABS; i++)
{
for (j = 0; j<labsizes[i]; j++)
{
if (cscLabs[i]->getComputers()[j].whoIsLoggedIn() == id)
{
(cscLabs[i]->getComputers())[j].signoff();
cout << "User " << id << " is logged off." << endl;
return;
}
}
}
cout << "That user is not logged in." << endl;
return;
}
void search(LabPtr cscLabs[], int labsizes[])
{
int id = -1, i, j;
while ((id < 0) || (id > 99999))
{
cout << "Enter the 5 digit ID number of the user to find:" << endl;
cin >> id;
}
for (i = 0; i<NUMLABS; i++)
{
for (j = 0; j<labsizes[i]; j++)
{
if (cscLabs[i]->getComputers()[j].whoIsLoggedIn() == id)
{
cout << "User " << id << " is in lab " << i + 1 <<
" at computer " << j + 1 << endl;
return;
}
}
}
cout << "That user is not logged in." << endl;
return;
}
int main()
{
LabPtr cscLabs[NUMLABS];
int labSizes[NUMLABS] = { 5, 6, 4, 3 };
string labNames[NUMLABS] = { "Lab-A", "Lab-B", "Lab-C", "Lab-D" };
createLabs(cscLabs, labNames, labSizes);
int choice = -1;
while (choice != 0)
{
cout << endl;
showLabs(cscLabs, labSizes);
cout << "MAIN MENU" << endl;
cout << "0) Quit" << endl;
cout << "1) Simulate login" << endl;
cout << "2) Simulate logoff" << endl;
cout << "3) Search" << endl;
cin >> choice;
switch (choice) {
case 1:
login(cscLabs, labSizes);
break;
case 2:
logoff(cscLabs, labSizes);
break;
case 3:
search(cscLabs, labSizes);
break;
default:
break;
};
}
destroyLabs(cscLabs);
return 0;
}
/ end of ComputerLabs_Exam.cpp
------------------------------------------------------------------------------------------------------------------------//Implementation File for Lab.cpp
//Header file Lab.h:
#include <iostream>
#include <string>
using namespace std;
#include "Computer.h"
#include "Lab.h"
namespace csc161
{
bool operator ==(const Lab_T& lab1, const Lab_T& lab2)
{
return (lab1.getLabSize() == lab2.getLabSize());
};
Lab_T::Lab_T(string p_lab_name, unsigned int p_lab_size) {
lab_name = p_lab_name;
computers = new Computer_T[p_lab_size];
for (unsigned int j = 0; j<p_lab_size; j++)
{
computers[j].reboot();
}
};
Lab_T::Lab_T(const Lab_T& p_lab) {};
Lab_T::Lab_T() {};
Lab_T::~Lab_T() {
delete[] computers;
};
std::string Lab_T::getLabName() const { return lab_name; };
void Lab_T::setLabSize(std::string p_lab_name) { };
unsigned int Lab_T::getLabSize() const { return lab_size; };
void Lab_T::setLabSize(unsigned int p_lab_size) { };
ComputerPtr Lab_T::getComputers() {
return computers;
};
ostream& operator <<(ostream& outs, const Lab_T& the_object)
{
{
name>::<Lab size><endl>
outs << "Lab - " << the_object.lab_name << " :: " << the_object.lab_size << endl;
return outs;
}
}
}
Explanation / Answer
Answer:
The changes made in the respective files details are mentioned below and the code changed is highlighted in bold letters. Only the changed code is given by name of the file and the modified code.
1)
ComputerLabs_Exam.cpp:
void showLabs(LabPtr cscLabs[], int labsizes[])
{
int i, j;
cout << "LAB STATUS" << endl;
cout << "Lab # Computer Stations" << endl;
for (i = 0; i < NUMLABS; i++)
{
cout << i + 1 << " ";
for (j = 0; j < labsizes[i]; j++)
{
cout << (j + 1) << ": ";
cout << cscLabs[i]->getComputers()[j];
}
cout << endl;
}
cout << endl;
//Here the lines are modified
}
int main()
{
int choice;
LabPtr cscLabs[NUMLABS];
int labSizes[NUMLABS] = { 5, 6, 4, 3 };
string labNames[NUMLABS] = { "Lab-A", "Lab-B", "Lab-C", "Lab-D" };
createLabs(cscLabs, labNames, labSizes);
while (true)
{
cout << endl;
showLabs(cscLabs, labSizes);
cout << "MAIN MENU" << endl;
cout << "0) Quit" << endl;
cout << "1) Simulate login" << endl;
cout << "2) Simulate logoff" << endl;
cout << "3) Search" << endl;
cin >> choice;
switch (choice)
{
case 0:
system("pause");
break;
case 1:
login(cscLabs, labSizes);
break;
case 2:
logoff(cscLabs, labSizes);
break;
case 3:
search(cscLabs, labSizes);
break;
default:
break;
};
}
destroyLabs(cscLabs);
system("pause");
return 0;
}
// end of ComputerLabs_Exam.cpp
2)
Lab.cpp
ostream& operator <<(ostream& outs, const Lab_T& the_object)
{
outs << "Lab - " << the_object.lab_name << " :: " << the_object.lab_size << endl;
return outs;
}
3)
When you are using the Visual Studio, in general while executing the .cpp files, it may ask for #include "stdafx.h".
So whenever you create a .cpp files include the above statement.
A sample output is generated in-order to show that there are no more errors in the code after modifying the code in the respective files as given above. The rest of the code is working fine.
Sample Output:
LAB STATUS
Lab # Computer Stations
1 1: Open 2: Open 3: Open 4: Open 5: Open
2 1: Open 2: Open 3: Open 4: Open 5: Open 6: Open
3 1: Open 2: Open 3: Open 4: Open
4 1: Open 2: Open 3: Open
MAIN MENU
0) Quit
1) Simulate login
2) Simulate logoff
3) Search
1
Enter the 5 digit ID number of the user logging in:
12345
Enter the lab number the user is logging in from (1-4):
1
Enter computer station number the user is logging in to (1-5):
2
LAB STATUS
Lab # Computer Stations
1 1: Open 2: 123453: Open 4: Open 5: Open
2 1: Open 2: Open 3: Open 4: Open 5: Open 6: Open
3 1: Open 2: Open 3: Open 4: Open
4 1: Open 2: Open 3: Open
MAIN MENU
0) Quit
1) Simulate login
2) Simulate logoff
3) Search
1
Enter the 5 digit ID number of the user logging in:
11223
Enter the lab number the user is logging in from (1-4):
1
Enter computer station number the user is logging in to (1-5):
1
LAB STATUS
Lab # Computer Stations
1 1: 112232: 123453: Open 4: Open 5: Open
2 1: Open 2: Open 3: Open 4: Open 5: Open 6: Open
3 1: Open 2: Open 3: Open 4: Open
4 1: Open 2: Open 3: Open
MAIN MENU
0) Quit
1) Simulate login
2) Simulate logoff
3) Search
1
Enter the 5 digit ID number of the user logging in:
22314
Enter the lab number the user is logging in from (1-4):
2
Enter computer station number the user is logging in to (1-6):
3
LAB STATUS
Lab # Computer Stations
1 1: 112232: 123453: Open 4: Open 5: Open
2 1: Open 2: Open 3: 223144: Open 5: Open 6: Open
3 1: Open 2: Open 3: Open 4: Open
4 1: Open 2: Open 3: Open
MAIN MENU
0) Quit
1) Simulate login
2) Simulate logoff
3) Search
1
Enter the 5 digit ID number of the user logging in:
32165
Enter the lab number the user is logging in from (1-4):
3
Enter computer station number the user is logging in to (1-4):
2
LAB STATUS
Lab # Computer Stations
1 1: 112232: 123453: Open 4: Open 5: Open
2 1: Open 2: Open 3: 223144: Open 5: Open 6: Open
3 1: Open 2: 321653: Open 4: Open
4 1: Open 2: Open 3: Open
MAIN MENU
0) Quit
1) Simulate login
2) Simulate logoff
3) Search
1
Enter the 5 digit ID number of the user logging in:
25413
Enter the lab number the user is logging in from (1-4):
4
Enter computer station number the user is logging in to (1-3):
3
LAB STATUS
Lab # Computer Stations
1 1: 112232: 123453: Open 4: Open 5: Open
2 1: Open 2: Open 3: 223144: Open 5: Open 6: Open
3 1: Open 2: 321653: Open 4: Open
4 1: Open 2: Open 3: 25413
MAIN MENU
0) Quit
1) Simulate login
2) Simulate logoff
3) Search
1
Enter the 5 digit ID number of the user logging in:
12457
Enter the lab number the user is logging in from (1-4):
2
Enter computer station number the user is logging in to (1-6):
6
LAB STATUS
Lab # Computer Stations
1 1: 112232: 123453: Open 4: Open 5: Open
2 1: Open 2: Open 3: 223144: Open 5: Open 6: 12457
3 1: Open 2: 321653: Open 4: Open
4 1: Open 2: Open 3: 25413
MAIN MENU
0) Quit
1) Simulate login
2) Simulate logoff
3) Search
3
Enter the 5 digit ID number of the user to find:
25413
User 25413 is in lab 4 at computer 3
LAB STATUS
Lab # Computer Stations
1 1: 112232: 123453: Open 4: Open 5: Open
2 1: Open 2: Open 3: 223144: Open 5: Open 6: 12457
3 1: Open 2: 321653: Open 4: Open
4 1: Open 2: Open 3: 25413
MAIN MENU
0) Quit
1) Simulate login
2) Simulate logoff
3) Search
3
Enter the 5 digit ID number of the user to find:
12457
User 12457 is in lab 2 at computer 6
LAB STATUS
Lab # Computer Stations
1 1: 112232: 123453: Open 4: Open 5: Open
2 1: Open 2: Open 3: 223144: Open 5: Open 6: 12457
3 1: Open 2: 321653: Open 4: Open
4 1: Open 2: Open 3: 25413
MAIN MENU
0) Quit
1) Simulate login
2) Simulate logoff
3) Search
2
Enter the 5 digit ID number of the user to find:
12345
User 12345 is logged off.
LAB STATUS
Lab # Computer Stations
1 1: 112232: Open 3: Open 4: Open 5: Open
2 1: Open 2: Open 3: 223144: Open 5: Open 6: 12457
3 1: Open 2: 321653: Open 4: Open
4 1: Open 2: Open 3: 25413
MAIN MENU
0) Quit
1) Simulate login
2) Simulate logoff
3) Search
2
Enter the 5 digit ID number of the user to find:
12457
User 12457 is logged off.
LAB STATUS
Lab # Computer Stations
1 1: 112232: Open 3: Open 4: Open 5: Open
2 1: Open 2: Open 3: 223144: Open 5: Open 6: Open
3 1: Open 2: 321653: Open 4: Open
4 1: Open 2: Open 3: 25413
MAIN MENU
0) Quit
1) Simulate login
2) Simulate logoff
3) Search
0
Press any key to continue . . .
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.