A
Amira
Following is my header file:
#ifndef PROTEIN_
#define PROTEIN_
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
class Protein { // class Protein
private:
std::string protName_;
std::string molWeight_;
std::string protFamily_;
public:
ProtWrite(int, int, int);
~ProtWrite();
ProtRead(int, int, int);
~ProtRead();
};
#endif //PROTEIN_
++++++++++++The cpp file is as follows:
#include <string>
#include <fstream>
#include "protein.h"
using namespace std;
//using std::cout;
Protein:rotWrite(int protName_, int molWeight_, int protFamily_)
{
ofstream myfile;
myfile.open ("protein.txt");
myfile << "<Protein>\n" << " <molWeight>" << molWeight_ << "</
molWeight>"
<< "\n</Protein>" << endl;
myfile.close();
};
int main(){
Protein prt;
std::cout << "Please enter the name: ";
std::getline(std::cin, prt.protName_);
std::cout << "Please enter the weight: ";
std::getline(std::cin, molWeight_);
std::cout << "Please enter the family: ";
std::getline(std::cin, protFamily_);
return 0;
}
Now, when I try to compile the code I get the error 'std::string
Protein:rotName_' is private. Somebody and advice?
Cheers,
Paul
#ifndef PROTEIN_
#define PROTEIN_
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
class Protein { // class Protein
private:
std::string protName_;
std::string molWeight_;
std::string protFamily_;
public:
ProtWrite(int, int, int);
~ProtWrite();
ProtRead(int, int, int);
~ProtRead();
};
#endif //PROTEIN_
++++++++++++The cpp file is as follows:
#include <string>
#include <fstream>
#include "protein.h"
using namespace std;
//using std::cout;
Protein:rotWrite(int protName_, int molWeight_, int protFamily_)
{
ofstream myfile;
myfile.open ("protein.txt");
myfile << "<Protein>\n" << " <molWeight>" << molWeight_ << "</
molWeight>"
<< "\n</Protein>" << endl;
myfile.close();
};
int main(){
Protein prt;
std::cout << "Please enter the name: ";
std::getline(std::cin, prt.protName_);
std::cout << "Please enter the weight: ";
std::getline(std::cin, molWeight_);
std::cout << "Please enter the family: ";
std::getline(std::cin, protFamily_);
return 0;
}
Now, when I try to compile the code I get the error 'std::string
Protein:rotName_' is private. Somebody and advice?
Cheers,
Paul