I have multiple errors with my class, either "string", a variable, or the template class isnt declared. Not sure whats wrong with my header files or how I'm setting it up.
Now my program uses 2 classes, one is a templated class that uses dynamic arrays in the private member, and the other class uses that templated class in the private member.
In the .cpp
#include <iostream>
#include <ostream>
#include <string>
#include "Classroom.h"
using namespace std;
bool Classroom::addStudent(const string& name){
return (classRoom.insert(name));
}
bool Classroom::removeStudent(const string& name)
{
return (classRoom.remove(name));
}
bool Classroom::containsStudent(const string& name)
{
return (classRoom.contains(name));
}
string Classroom::listAllStudents()
{
string name;
string data;
unsigned int i;
for (i=0;i<classRoom.size()-1; i++){
if (classRoom.at(i,data)){
name += data;
name += ", ";
}
}
if (i<classRoom.size()){
if (classRoom.at(i,data)){
name += data;
}
}
return (name);
}
In the .h
#ifndef CLASSROOM_H
#define CLASSROOM_H
#include "UniqueVector.h"
class Classroom {
public:
/*— If a student named name is not already on the
classroom roster, adds a new student named name to the classroom roster and returns true;
otherwise, returns false.*/
bool addStudent(const std::string& name);
/* — If a student named name is on the classroom
roster, removes the student named name from the classroom roster and returns true; otherwise,
returns false.*/
bool removeStudent(const std::string& name);
/* — If a student named name is on the classroom
roster, returns true; otherwise, returns false. */
bool containsStudent(const std::string& name);
/*— Returns a string containing the names of the students in the
classroom, separated by commas.*/
std ::string listAllStudents();
private:
UniqueVector<string> classRoom;
};
#endif
I'm getting templated argument 1 invalid or classRoom from the private member of Classroom isn't declared.
Also an error about I UniqueVector classRoom; with string not declared
I tried using std:: UniqueVector classRoom; is there way so that I dont have to include std:: in every instance of string?