| | |
Can't get strings to work...
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Nov 2007
Posts: 22
Reputation:
Solved Threads: 0
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.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:
C++ Syntax (Toggle Plain Text)
/* * 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: };
C++ Syntax (Toggle Plain Text)
/* * 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(); }
Last edited by pocku; Oct 15th, 2009 at 9:11 pm.
•
•
Join Date: Nov 2007
Posts: 22
Reputation:
Solved Threads: 0
0
#4 Oct 16th, 2009
•
•
•
•
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?
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.
Last edited by pocku; Oct 16th, 2009 at 12:43 am.
![]() |
Similar Threads
- Sql server/connection strings - aargh! (ASP.NET)
- Reading strings from a file... (C++)
- Quicksort strings? (C++)
- Help With Inputting Strings (C++)
- URGENT help needed with strings. (C++)
- C++ Bubble sort not working with array of records, does work with simple array. (C++)
- Initializing an array of strings and printing it. (C++)
- problem in concatenation of 2 strings (C)
- Sorting a 2d array of strings in C++?? (C++)
- strings in c (C++)
Other Threads in the C++ Forum
- Previous Thread: How to extract a row of a 2d Vector
- Next Thread: Simple Linked List: crashes
| Thread Tools | Search this Thread |
api array arrays based binary bitmap c++ c/c++ calculator char char* class classes code coding compile console conversion convert count data database delete deploy developer dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game generator getline givemetehcodez google graph gui homeworkhelp iamthwee ifstream input int java lib linkedlist linker list loop looping loops map math matrix memory multiple news node number numbertoword output pointer problem program programming project python random read recursion recursive reference rpg sorting string strings temperature template test text text-file tree url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






