I want to use the string class in my program but I keep getting the following errors:

process.cpp:10: error: 'string' has not been declared
process.cpp:10: error: prototype for 'Process:: Process(int, int, int)'
does not match any in class 'Process'
process.h:14: error: candidates are: Process:: Process(const Process&)
process.h:16: error: Process:: Process(int, char*, int)
process.cpp: In constructor 'Process:: Process(int, int, int)':
process.cpp:14: error: invalid conversion from 'intâ to âchar*'
make: *** [process.o] Error 1

I don't understand why I'm getting this since my code doesn't seem to differ from the examples I found in tutorials too much:

/*
 * process.h
 *
 *  Created on: Oct 13, 2009
 *      Author: NTUser1
 */

#ifndef PROCESS_H_
#define PROCESS_H_

#include "thread.h"

#include <string>
#include <iostream>

using namespace std;

class Process : public Thread
{
public:
	Process(int at, string process, int bt);

	int arrivalTime;	// arrival time of a process
	string name;			// process name, e.g., P0, P1, P2
	int burstTime;		// CPU burst time of a process
	int remainTime;		// the remaining burst time of a process

	void run();

private:

};
/*
 * process.cpp
 *
 *  Created on: Oct 13, 2009
 *      Author: NTUser1
 */

#include "process.h"

Process::Process(int at, string process, int bt){

	arrivalTime = at;
	burstTime = bt; //etc for the rest of the vars
	name = process;
}

void Process::run(){
	state = RUNNING;
	sleep(burstTime);
	stop();
}

what compiler/version are you using ?

I'm not sure which thread library you are using, but even without it you are missing an #endif at the end of your header. I'm not sure if that's the main issue. Are there other errors besides the ones you pasted in?

I'm not sure which thread library you are using, but even without it you are missing an #endif at the end of your header. I'm not sure if that's the main issue. Are there other errors besides the ones you pasted in?

I'm using pthread but no, I just forgot to paste in the #endif, it's there in my code. The errors I've posted are the only the ones I'm getting...

what compiler/version are you using ?

Not too sure as I am doing this on a university computer and I don't know where I can go check at this time.

what is the command line to compile something? Or are you using an IDE? Do you know what operating system (e.g. *nix or MS-Windows)?

what is the command line to compile something? Or are you using an IDE? Do you know what operating system (e.g. *nix or MS-Windows)?

I use either g++ or make (to compile multiple files together). I'm programming this on a terminal on linux.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.