creating object in c++ using input file -
i familiar java , c++ not strong spot..
i trying write algorithm cpu scheduler of code syntax error free stuck 1 problem.
my program uses 2 classes process , processqueue
my main looks this
int main(){ fstream f; processqueue pq; f.open("input.txt"); if (!f) { cout << "file not found"; }else{ int noofprocess; f >> noofprocess; process *p; p = new process[noofprocess]; (int = 0;i<noofprocess;i++){ int arivaltime; int cputime; int proritynumber; f >> arrivaltime; f >> cputime; f >> proritynumber; p[i] = new process(arrivaltime,cputime,proritynumber); } return 0; } but p[i] causing trouble.. not able use parametric constructor,setters.
it gives following error

change
p[i] = new process(arrivaltime,cputime,proritynumber); to
p[i] = process(arrivaltime,cputime,proritynumber); as p[pi] of type process
also use std::array or str::vector
Comments
Post a Comment