URGENT: how to use constructors and capture keyboard entries

I want to start by saying thank u to all the experts that have taken their time to make this site a success. Thank you very much, I really appreciate the time you take to do this. Thank you.

I have 2 problems:
1) I am trying to overload a class to call it with both integer array values and also pass instructions from a file as follows:

public:
prom::prom() {} //constructor defined with no arguments


prom::prom(char *file_name) //constructor to read input from file
{
//ifstream in("instrf.txt");
ifstream in(file_name);
string p1, line;
while(getline(in, line))
p1 += line + ",";
}


it works this way, i tried to execute the program this way
prom v;
int pp[]={121,413,523,314,600};
v.program(pp);

and it executes, works well

but if i try reading from a file
Eprom v("instr.dat");
v.program("instr.dat");

the values of the text file instr.dat are 123,421, 521.

it doesnt work, gives me errors about passing integer to the method defination or cant pass string.

Please show me how to execute it in my .cpp file by passing the instructions from the file.

2) the second problem is

i am trying to pass value captured from keyboard from a class to another class as follows:

void Input::Inputentry()
{
const int MAXINSTR = 6;
Input inst[MAXINSTR];

cout<< "Enter 600 when finished ";

cin >> temp_instr; //[i];

value = temp_instr;
}

I then tried to include this in my .cpp file

Input y; //Input is d class above for keyboard entry
int pp1[6] ;

int i=0;
do
{

y.Inputentry();
int p=y.Inputreturn();

pp1[i] = p;
if ( p == 600)
{
break;
}
cout<<" pp1 is"<<pp1[i]<<endl;

i++;
} while (i < 6) ;

but i keep on getting this error message of cant convert int to array.

All I wanted to do is capture integer values from keyboard, an array preferable, example 123,321, and pass them from one class to another class or the .cpp. But i havent been able to do that.

Please show me how.
Thankx for evrything. All your effort is appreciated.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories