lost!!! I took a homework assignment that worked written in just main and for practice I wanted to make them classes with pointers and have one derived class of base. Although the while loop, for the most part worked before it was turned into a class, it now does not work. I tried using If statement but I am haveing problems constructing. Now I'm totally at a lose as what to do.
error C2664: 'strcmp' : cannot convert parameter 1 from 'char *[20]' to 'const char *
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
C1903: unable to recover from previous error(s); stopping compilation
Error executing cl.exe.
sample.obj - 2 error(s), 0 warning(s)
*************************************************************
#include <iostream.h> // This is used for the cout's and cin's
#include <fstream.h> // This is used to read from and write to files
#include <stdlib.h> // This gives us the exit(1) command
#include <string.h>
class file1
{
protected:
char *filename[12];
char *name[20];
public:
file1()
{ cout << "Enter the filename: ";
cin >> *filename;
cout << endl;
}
void file();
//void display();
};
void file1::file()
{
// Creating an instance of outbound data
ofstream outfile;
outfile.open(*filename, ios::app);
if (outfile.fail())
{
cout <<"The file failed to open" <<endl;
exit(1);
}
cout << "Enter names to the file called: "<< *filename <<endl;
cout << "Enter end to stop entering names." << endl;
cout << endl;
//loop to enter names and keep count
//section having problems with!
while(strcmp(name, "end"))
{
int count = 0;
cout << "Enter names: " << endl;
cin >> *name;}
//send data to outfile
outfile << *name;
outfile << "\n";
count++;
cout << endl;
}
// Closing the outfile to free up memory
outfile.close();
return ;
}
class filederived : file1
{
public:
char derived();
}
filederived::derived()
{
int count = 0;
// Creating an instance of inbound data
ifstream infile;
// Opening the infile "filename" for reading
infile.open(*filename);
//to view amount of names entered
cout << "You have entered " << count << " names " << "in file " << *filename << "\n\n";
while(count>1)
{
// Reading the contents of "filename"
infile >> *name;
//to view names entered into the file
cout <<"The name you have entered is: " << *name << endl;
count--;
return ;
}
infile.close();
return ;
}
int main()
{
file1 a;
filederived b;
a.file();
b.derived();
return 0;
}
:rolleyes: