hi guys, i cant' seem to cout the object. the code goes below:
----------------
#include <iostream.h>
#include <fstream.h>
class vl {
private:
char* ptr;
public:
vl() {
ptr = new char[8];
strcpy(ptr,"00000000");
}
void read(char* linefeed) {
delete [] ptr;
ptr = new char[strlen(linefeed)];
strcpy(ptr,linefeed);
}
void display() {
cout << ptr << endl;
}
~vl() {
delete [] ptr;
}
};
void main() {
fstream infile;
char temp[120];
infile.open("hp.txt",ios::in);
while (infile) {
vl integer;
infile.get(temp,120,'\n'); infile.get();
if ((!isdigit(temp[0])) || (!isalpha(temp[0]))) { continue; }
integer.read(temp);
integer.display();
cout << endl;
}
cout << "END OF FILE" << endl;
infile.close();
}
---------------
and e.g of a hp.txt file would be,
---------------
1234
-1234
---------------
right now the priority would be echo out the object... but i cant seem to do it, anyone can help?