Hello. I am trying to currently get back into coding C++. It's been quite a while so some syntax and what not I have forgotten. I am trying to compile this code but for some reason it doesn't seem to recognize string even though it is included in the main.cpp. The error is error C2146: syntax error : missing ';' before identifier 'currentJob' Any help would be very much appreciated. Thanks
Partition.h
Code:
class Partition
{
public:
int maxSize;
int size;
int number;
bool status; //True = Free, False = Busy
int unused;
string currentJob;
Partition (int,int);
int getMaxSize(){return maxSize;}
int getSize(){return size;}
int getNumber(){return number;}
int getStatus(){return status;}
int getUnused(){return unused;}
string getJob(){return currentJob;}
void setMaxSize(int m){maxSize = m;}
void setSize(int s){size = s;}
void setNumber(int n) {number = n;}
void setStatus(bool a) {status = a;}
void setUnused(int jobSize) {maxSize - jobSize;}
void addJob(string jobName) {currentJob = jobName;}
};
Partition::Partition(int num, int psize)
{
number = num;
size = psize;
}
Job.h
Code:
class Job
{
public:
int currentPartitionNumber;
string name;
int size;
bool status; //True = Run, False = Wait
Job (string,int);
void setName(string n){name = n;}
void setSize(int s){size = s;}
void setStatus(bool stat){status = stat;}
void setPartition(int partitionNumber) {currentPartitionNumber = partitionNumber;}
string getName(){return name;}
int getSize(){return size;}
bool getStatus(){return status;}
int getPartition(){return currentPartitionNumber;}
};
Job::Job(string jobName, int jsize)
{
name = jobName;
size = jsize;
}
Main.cpp
Code:
#include <iostream>
#include <string>
#include "Partition.h"
#include "Job.h"
using namespace std;
int main ()
{
int maxSize;
Partition pList [];
int partitionNumber;
cout << "What is the total memory size?"
cin >> maxSize;
do
{
cout << "How many partitions are there?"
cin >> partitionNumber;
if(partitionNumber > 5)
cout << "Please enter a number smaller than 5"
}while(partitionNumber > 5);
return 0;
}