Error c2664 in VS 2013 C++ - c++

So, I have a class called "music" and when I try to compile the code, it gives me the following errors:
Error 13 error C2664: 'music::music(const music &)' : cannot convert
argument 2 from 'const char [5]' to 'char' c:\users\andrei
bordeianu\documents\visual studio
2013\projects\mediaplus\mediaplus\source.cpp 362 1 MediaPlus
14 IntelliSense: no instance of constructor "music::music" matches
the argument list
argument types are: (const char [5], const char [5], const char [4], const char [12], int, const char [8], const char [5],
int) c:\Users\Andrei Bordeianu\Documents\Visual Studio
2013\Projects\MediaPlus\MediaPlus\Source.cpp 361 11 MediaPlus
This is the class:
// Music class.
class music {
char* song;
properties musicProperties;
public:
music() {
cout << "Apel constructor default muzica." << endl;
this->song = NULL;
}
music(char* songName, char name, char type, char path, float size, char artist, char title, int year) {
cout << "Apel constructor cu parametri muzica." << endl;
if (songName) {
this->song = new char[strlen(songName) + 1];
strcpy(this->song, songName);
musicProperties.setDataMusic(name, type, path, size, artist, title, year);
} else {
songName = NULL;
}
}
music operator=(const music &songName) {
cout << "Supraincarcare operator = pentru muzica." << endl;
this->song = new char[strlen(songName.song) + 1];
strcpy(this->song, songName.song);
}
music(const music &songName) {
cout << "Apel constructor de copiere muzica." << endl;
if (songName.song) {
this->song = new char[strlen(songName.song) + 1];
strcpy(this->song, songName.song);
} else {
song = NULL;
}
}
~music() {
cout << "Apel destructor muzica." << endl;
if (this->song) {
cout << "Apel destructor pentru: " << this->song << endl;
delete[] song;
}
}
friend char* getMusic(const music& m);
friend ostream& operator<<(ostream& out, music& m);
friend istream& operator>>(istream& in, music& m);
};
and this is the main:
void main() {
music m1;
music m2("ceva", "ceva", "mp3", "c:\data\music", 38, "Rihanna", "Stay", 2013);
music m3 = m1;
}
Ok, tried your suggestions, and changed to string, and now my app looks like this:
#include <iostream>
#include <string>
using namespace std;
// Properties class.
class properties{
string name;
string type;
string path;
float size;
// For images.
int width;
int height;
// For music.
string artist;
string title;
int year;
public:
properties() {
cout << "Apel constructor default proprietati." << endl;
this->name = "";
this->type = "";
this->path = "";
this->size = 0;
this->width = 0;
this->height = 0;
this->artist = "";
this->title = "";
this->year = 0;
}
properties(string name, string type, string path, float size, int width, int height, string artist, string title, int year) {
cout << "Apel constructor cu parametrii proprietati." << endl;
this->name = name;
this->type = type;
this->path = path;
this->size = size;
this->width = width;
this->height = height;
this->artist = artist;
this->title = title;
this->year = year;
}
char getName() {
return this->name;
}
char getType() {
return this->type;
}
char getPath() {
return this->path;
}
float getSize() {
return this->size;
}
int getWidth() {
return this->width;
}
int getHeight() {
return this->height;
}
char getArtist() {
return this->artist;
}
char getTitle() {
return this->title;
}
int getYear() {
return this->year;
}
void setName(string name){
this->name = name;
}
void setPath(string path){
this->path = path;
}
void setType(string type){
this->type = type;
}
void setSize(float size){
this->size = size;
}
void setWidth(int width){
this->width = width;
}
void setHeight(int height){
this->height = height;
}
void setArtist(string artist){
this->artist = artist;
}
void setTitle(string title){
this->title = title;
}
void setYear(int year){
this->year = year;
}
void setDataGeneral(string name, string type, string path, float size){
cout << "Apel setter general properties." << endl;
setName(name);
setType(type);
setPath(path);
setSize(size);
}
void setDataMusic(string name, string type, string path, float size, string artist, string title, int year){
cout << "Apel setter music properties." << endl;
setName(name);
setType(type);
setPath(path);
setSize(size);
setArtist(artist);
setTitle(title);
setYear(year);
}
void setDataImages(string name, string type, string path, float size, int width, int height){
cout << "Apel setter image properties." << endl;
setName(name);
setType(type);
setPath(path);
setSize(size);
setWidth(width);
setHeight(height);
}
// Constructor de copiere.
properties(const properties& p){
cout << "Apel constructor copiere properties." << endl;
this->name = p.name;
this->type = p.type;
this->path = p.path;
this->size = p.size;
this->width = p.width;
this->height = p.height;
this->artist = p.artist;
this->title = p.title;
this->year = p.year;
}
~properties(){
cout << "Apel destructor properties." << endl;
};
};
// Music class.
class music {
char* song;
properties musicProperties;
public:
music() {
cout << "Apel constructor default muzica." << endl;
this->song = NULL;
}
music(char* songName, string name, string type, string path, float size, string artist, string title, int year) {
cout << "Apel constructor cu parametri muzica." << endl;
if (songName) {
this->song = new char[strlen(songName) + 1];
strcpy(this->song, songName);
musicProperties.setDataMusic(name, type, path, size, artist, title, year);
} else {
songName = NULL;
}
}
music operator=(const music &songName) {
cout << "Supraincarcare operator = pentru muzica." << endl;
this->song = new char[strlen(songName.song) + 1];
strcpy(this->song, songName.song);
}
music(const music &songName) {
cout << "Apel constructor de copiere muzica." << endl;
if (songName.song) {
this->song = new char[strlen(songName.song) + 1];
strcpy(this->song, songName.song);
} else {
song = NULL;
}
}
~music() {
cout << "Apel destructor muzica." << endl;
if (this->song) {
cout << "Apel destructor pentru: " << this->song << endl;
delete[] song;
}
}
friend char* getMusic( music& m); //const
friend ostream& operator<<(ostream& out, music& m);
friend istream& operator>>(istream& in, music& m);
};
// Movies class.
class movies {
char* movie;
properties moviesProperties;
public:
movies() {
cout << "Apel constructor default filme." << endl;
movie = NULL;
}
movies(char* movieTitle, string name, string type, string path, float size) {
cout << "Apel constructor cu parametri filme." << endl;
if (movieTitle) {
this->movie = new char[strlen(movieTitle) + 1];
strcpy(this->movie, movieTitle);
moviesProperties.setDataGeneral(name, type, path, size);
} else {
movie = NULL;
}
}
movies operator=(const movies &movieTitle) {
cout << "Supraincarcare operator = pentru filme." << endl;
this->movie = new char[strlen(movieTitle.movie) + 1];
strcpy(this->movie, movieTitle.movie);
}
movies(const movies &movieTitle) {
cout << "Apel constructor de copiere filme." << endl;
if (movieTitle.movie) {
this->movie = new char[strlen(movieTitle.movie) + 1];
strcpy(this->movie, movieTitle.movie);
} else {
movie = NULL;
}
}
~movies() {
cout << "Apel destructor filme." << endl;
if (this->movie) {
cout << "Apel destructor pentru: " << this->movie << endl;
delete[] movie;
}
}
friend char* getMovies(const movies& m);
friend ostream& operator<<(ostream& out, movies& m);
friend istream& operator>>(istream& in, movies& m);
};
// Images class.
class images {
char* image;
properties imagesProperties;
public:
images() {
cout << "Apel constructor default imagini." << endl;
image = NULL;
}
images(char* imageName, string name, string type, string path, float size, int width, int height) {
cout << "Apel constructor cu parametri imagini." << endl;
if (imageName) {
this->image = new char[strlen(imageName) + 1];
strcpy(this->image, imageName);
imagesProperties.setDataImages(name, type, path, size, width, height);
} else {
image = NULL;
}
}
images operator=(const images &imageName) {
cout << "Supraincarcare operator = pentru imagini." << endl;
this->image = new char[strlen(imageName.image) + 1];
strcpy(this->image, imageName.image);
}
images(const images &imageName) {
cout << "Apel constructor de copiere muzica." << endl;
if (imageName.image) {
this->image = new char[strlen(imageName.image) + 1];
strcpy(this->image, imageName.image);
}
else {
image = NULL;
}
}
~images() {
cout << "Apel destructor muzica." << endl;
if (this->image) {
cout << "Apel destructor pentru: " << this->image << endl;
delete[] image;
}
}
friend char* getImages(const images& i);
friend ostream& operator<<(ostream& out, images& i);
friend istream& operator>>(istream& in, images& i);
};
char* getMovies(const movies& m) {
if (m.movie)
return m.movie;
else
return NULL;
}
char* getImages(const images& i) {
if (i.image)
return i.image;
else
return NULL;
}
char* getMusic(music& songName) { //const
if (songName.song)
return songName.song;
else
return NULL;
}
ostream& operator<<(ostream& out, music& s) {
out << "Melodia este: " << s.song << endl;
return out;
}
istream& operator>>(istream& in, music& s) {
char buffer[20];
cout << "Melodia: ";
in >> buffer;
s.song = new char[strlen(buffer) + 1];
strcpy(s.song, buffer);
return in;
}
void main() {
music m1;
music m2("ceva", "ceva", "mp3", "c:\data\music", 38, "Rihanna", "Stay", 2013);
music m3 = m1;
//cout << getMusic(m2) << endl;
//cout << m2;
//cin >> m2;
//cout << m2;
}
and it gives me the following error(s):
Error 1 error C2440: 'return' : cannot convert from 'std::string' to
'char' c:\users\andrei bordeianu\documents\visual studio
2013\projects\mediaplus\mediaplus\source.cpp 50 1 MediaPlus
etc...
What can I to to resolve this issue ? Thanks!

You should try
music(char* songName, char* name, char* type, char* path, float size, char* artist, char* title, int year);
since char is a single character not pointer to a C string. Even better you should use a modern string class instead of old pointer stuff.

You're trying to pass string types ("ceva", "mp3", etc) into char parameters. To solve this, change your constructor parameters from char to string.

In the signature, the function accpects a char for name, but you send a char*.
music(char* songName, char name, char type, char path, float size, char artist, char title, int year)
I think it should be:
music(char* songName, char* name, char* type, char* path, float size, char* artist, char* title, int year)

You got your anwser, use string types or pointers.
As to why this is happening: You are passing characters as values, which mean they get their own new char array instance, this is clashing with the const instance of the argument. This is why the first argument (which was an explicit pointer) didn't cause an error.

Related

LMS error no operator = matches these operands

So for practice purposes I am creating a library management system using composition, to understand and practice the concept of composition.so i have a book class and a user class. i am composing a pointer of book class in the user class. i am using dma (dynamic memory allocation) for the add function.but i am getting this error that i am unable to debug.
Error (active) E0349 no operator "=" matches these operands PRAcTice
here's the whole code for understanding
#ifndef LMS_H
#define LMS_H
#include <iostream>
#include <string>
using namespace std;
class book {
private:
string bname;
int ISBN;
string author;
string publisher;
public:
book(string n = " ", int i = 0, string a = " ", string p = " ") {
bname = n;
ISBN = i;
author = a;
publisher = p;
}
void setbname(string a) {
bname = a;
}
string getbname() {
return bname;
}
void setisbn(int b) {
ISBN = b;
}
int getisbn() {
return ISBN;
}
void setauthor(string c) {
author = c;
}
string getauthor() {
return author;
}
void setpublisher(string d) {
publisher = d;
}
string getpublisher() {
return publisher;
}
friend ostream & operator << (ostream & COUT, book & rhs);
};
ostream & operator << (ostream & COUT, book & rhs) {
COUT << "Book Name: " << rhs.getbname() << endl;
COUT << "ISBN: " << rhs.getisbn() << endl;
COUT << "Author: " << rhs.getauthor() << endl;
COUT << "Publisher: " << rhs.getpublisher() << endl;
}
class user {
private:
string name;
int id;
string password;
book * b;
int bno;
public:
user(string m = " ", int q = 0, string n = " ", book * bx = NULL, int no = 0) {
name = m;
id = q;
password = n;
b = bx;
}
void setname(string a) {
name = a;
}
string getbname() {
return name;
}
void setid(int b) {
id = b;
}
int getid() {
return id;
}
void setpassword(string c) {
password = c;
}
string getpassword() {
return password;
}
void setbno(int d) {
bno = d;
}
int getisbn() {
return bno;
}
void setbook(book a[]) {
b = new book[bno];
for (int i = 0; i < bno; i++) {
b[i].setbname(a[i].getbname());
b[i].setisbn(a[i].getisbn());
b[i].setauthor(a[i].getauthor());
b[i].setpublisher(a[i].getpublisher());
}
}
book * getbook() {
return b;
}
book * add(book b) {
b = new book[bno + 1];
}
};
#endif // !"LMS_H"
The problem is that the object b on the left hand side of the assignment b = new book[bno + 1]; is of type book while the object on the right hand side is of type book*.
//---v----------------------->type of object b is book
b = new book[bno + 1];
//-------^^^^^^^^^^^^^^^^----type of the resulting object on rhs is book*
That is there is a mismatch in the type on the left hand side and right hand side of the assignment and since there is no overloaded operator= that has parameter of type book and book* you get the mentioned error.
Additionally you're missing return statements inside operator<< and inside add.

I can't return the const char * variable using inheritance setter and getter

I can print the correct value in setter function but when I try to return the same variable using getter there is no output. Here is my code. Anyone has idea on how I correct my code?
class Student {
public:
char age;
double height;
double gpa;
int getAge();
void setAge(int *);
protected:
const char * name;
};
class Male :Student {
public:
void setName(const char * s);
const char * getName();
};
void Male::setName(const char * s){
const char* name = s;
std::cout << name << std::endl;
}
const char* Male::getName() {
return name; //I can't return the value of variable name.
std::cout << name << std::endl;
}
void Student::setAge(int* c) {
age = *c;
}
int Student::getAge() {
return age;
}
int main() {
Student jason;
Male myName;
int edad = 30;
jason.height = 162;
jason.gpa = 1.5;
jason.setAge(&edad);
myName.setName("James");
std::cout << jason.height << "\n" << jason.getAge() << "\n" << jason.gpa << "\n" << std::endl;
system("pause");
return 0;
}
I don't know why I can't return the const char variable. :(
void Male::setName(const char * s) {
name = s;
std::cout << name << std::endl;
}
You need to set s to the member variable name instead of creating a local variable in the method

C++ Copy Constructor & Operator Overloading

I am relatively new to classes and was introduced to copy constructors and overloading last week. I am supposed to overload the = operator and use it to assign multiple variables using the class name.
For some reason, running the program causes a popup saying
program.cpp has stopped responding.
I am positive there are minor/major things that I am missing due to me being a rookie with objects in C++.
Any advice is very much appreciated!
#include<iostream>
#include<string>
using namespace std;
class Employee
{
private:
char *name;
string ID;
double salary;
public:
Employee() {}
Employee(char *name, string eid, double salary) {}
Employee(const Employee &obj)
{
name = new char;
ID = obj.ID;
salary = obj.salary;
}
~Employee() {}
void setName(char *n)
{
name = n;
}
void setID(string i)
{
ID = i;
}
void setSalary(double s)
{
salary = s;
}
char getName()
{
return *name;
}
string getID()
{
return ID;
}
double getSalary()
{
return salary;
}
Employee operator = (Employee &right)
{
delete[] name;
ID = right.ID;
salary = right.salary;
return *this;
}
};
int main()
{
Employee e1("John", "e222", 60000), e2(e1), e3, e4;
e3 = e4 = e2;
e2.setName("Michael");
e2.setSalary(75000);
e3.setName("Aaron");
e3.setSalary(63000);
e4.setName("Peter");
cout << "\nName: " << e1.getName() << "\nID: " << e1.getID() << "\nSalary: " << e1.getSalary() << endl;
cout << "\nName: " << e2.getName() << "\nID: " << e2.getID() << "\nSalary: " << e2.getSalary() << endl;
cout << "\nName: " << e3.getName() << "\nID: " << e3.getID() << "\nSalary: " << e3.getSalary() << endl;
cout << "\nName: " << e4.getName() << "\nID: " << e4.getID() << "\nSalary: " << e4.getSalary() << endl;
return 0;
}
There are several issues with this code.
The first issue is in the constructor Employee(char *name, string eid, double salary) {} which is just doing nothing and ignoring the passed data whereas it should be using it to initialize the fields (class member data).
Employee(char *name, string eid, double salary)
{
const size_t bufferSize = strlen(name) + 1;
this->name = new char[bufferSize];
memcpy(this->name, name, bufferSize);
this->ID = eid;
this->salary = salary;
}
The second issue is in the copy constructor Employee(const Employee &obj) , where you are just initializing the name (with single byte of char) and that's it. What the copy constructor suppose to do is initialize the fields (class members) of the class with the fields of the class object being passed to it.
Employee(const Employee &obj)
{
const size_t bufferSize = strlen(name) + 1;
this->name = new char[bufferSize];
memcpy(this->name, name, bufferSize);
ID = obj.ID;
salary = obj.salary;
}
the third issue is with the default constructor which is suppose to initialize the name pointer with the NULL so that the destructor could clean it up nicely:
Employee() : name(NULL) {}
~Employee()
{
if (NULL != name)
delete[] name;
}
the fourth and last problem is with the assignment operator that's suppose to properly initialize the name member data instead of deleting it (which doesn't make sense)
Employee operator = (Employee &right)
{
if (NULL != this->name)
delete[] this->name;
const size_t bufferSize = strlen(right.name) + 1;
this->name = new char[bufferSize];
memcpy(this->name, right.name, bufferSize);
ID = right.ID;
salary = right.salary;
return *this;
}
The problem is this line:
delete[] name;
You shouldn't delete anything you haven't allocated with new first. If you delete the above line, your program kind of works. :)
Here's a slightly revised version of your program that works:
#include<iostream>
#include<string>
using namespace std;
class Employee
{
private:
char *name;
string ID;
double salary;
public:
Employee() {}
Employee(char *name, string eid, double salary)
: name (name) // ADDED THESE
, ID(eid)
, salary(salary)
{
}
Employee(const Employee &obj)
{
name = obj.name; // WAS: new char;
ID = obj.ID;
salary = obj.salary;
}
~Employee() {}
void setName(char *n)
{
name = n;
}
void setID(string i)
{
ID = i;
}
void setSalary(double s)
{
salary = s;
}
char * getName()
{
return name;
}
string getID()
{
return ID;
}
double getSalary()
{
return salary;
}
Employee operator = (const Employee &right)
{
name = right.name; // WAS: delete[] name;
ID = right.ID;
salary = right.salary;
return *this;
}
};
int main()
{
Employee e1("John", "e222", 60000), e2(e1), e3, e4;
e3 = e4 = e2;
e2.setName("Michael");
e2.setSalary(75000);
e3.setName("Aaron");
e3.setSalary(63000);
e4.setName("Peter");
cout << "\nName: " << e1.getName() << "\nID: " << e1.getID() << "\nSalary: " << e1.getSalary() << endl;
cout << "\nName: " << e2.getName() << "\nID: " << e2.getID() << "\nSalary: " << e2.getSalary() << endl;
cout << "\nName: " << e3.getName() << "\nID: " << e3.getID() << "\nSalary: " << e3.getSalary() << endl;
cout << "\nName: " << e4.getName() << "\nID: " << e4.getID() << "\nSalary: " << e4.getSalary() << endl;
return 0;
}

Constructor with a array type of another class

This is the photo of the model I have to resolve:
I have this class:
#include<iostream>
#include<fstream>
using namespace std;
class Word
{
protected:
char *value;
char type[20];
int noChars;
static int noWords;
public:
Word(char *value, char *type)
{
this->noChars = 0;
this->value = new char[strlen(value) + 1];
strcpy(this->value, value);
strcpy(this->type, type);
Word::noWords++;
}
Word()
{
this->noChars = NULL;
this->value = NULL;
strcpy(this->type,"Nedeterminat");
}
void operator=(Word &x)
{
this->noChars = x.noChars;
strcpy(this->type, x.type);
this->value = new char[strlen(x.value) + 1];
strcpy(this->value, x.value);
}
Word(const Word& x){
this->noChars = x.noChars;
strcpy(this->type, x.type);
this->value = new char[strlen(x.value) + 1];
strcpy(this->value, x.value);
}
char* getValue()
{
return this->value;
}
void setType(char* x)
{
if (x == NULL)
{
throw new exception("Tip gresit!");
}
else
{
strcpy(this->type, x);
}
}
char &operator[](int i)
{
if (i >= 0 && i <= (strlen(this->value) - 1))
{
return this->value[i];
}
else
cout << endl << "Eroare indice: " << i;
}
static int getNoWords()
{
return Word::noWords;
}
operator int()
{
return this->noChars;
}
friend ostream& operator<<(ostream&, Word&);
friend istream& operator>>(istream&, Word&);
};
ostream& operator<<(ostream& consola, Word& x)
{
consola << "Value: " << x.getValue() << endl;
consola << "Type: " << x.type << endl;
consola << "NoChars: " << x.noChars << endl;
return consola;
}
istream& operator>>(istream& consola, Word& x){
cout << "Value: "; consola >> x.value;
cout << "Type: "; consola >> x.type;
cout << "NoChars: "; consola >> x.noChars;
return consola;
}
int Word::noWords = 0;
class Dictionary{
private:
char *language;
int noWords;
bool isOnline;
Word v[100];
public:
Dictionary(char *language, Word w, int noWords, bool isOnline)
{
this->language = new char[strlen(language) + 1];
strcpy(this->language, language);
for (int i = 0; i < 100; i++)
{
this->v[i] = w;
}
this->noWords = noWords;
this->isOnline = isOnline;
}
};
int main()
{
//1
Word w1("exam", "noun");
/*Word w2;*/
Word w3 = w1;
cout << w3;
//2
cout << endl << "Word value: " << w3.getValue();
Word w2("to take", "noun");
w2.setType("verb");
//3
w3 = w2;
cout << endl << w3;
Word *pw = new Word("pointer", "noun");
delete pw;
//4
cin >> w3; cout << w3;
char character = w3[2];
cout << endl << character;
//5
double noChars = (int)w1;
cout << endl << noChars;
cout << endl << Word::getNoWords() << endl;
//6
Dictionary dictionary1("English", NULL, 0, false);
}
I have this main:
Dictionary dictionary1("English", NULL, 0, false);
How should I change the constructor to work? I receive a error :
Arrgument types are:(const char[8],int,int,bool);
And how should I write the default constructor?
NULL cannot be assigned to Word. Try Word() instead which will call the default constructor to Word. Consider changing that function parameter to const Word& - anonymous temporaries are allowed to bind to const references.
I'd prefer to see a std::string as the type for the member variable language; using a const std::string& as the function parameter. Then you will not have to worry about a subsequent delete call, and defining your own assignment operators and copy constructors. Currently, your class leaks memory.
You can not Assign null to the type Word. If you want to default it you should pass something like word()
Dictionary dictionary1("English", word(), 0, false);
EDIT:
The better approach,IMO, that will work for the same main() you have is like this:
class Dictionary{
private:
std::string language;
int noWords;
bool isOnline;
std::array<Word,100> v;
public:
Dictionary(std::string const& language, Word* w, int noWords, bool isOnline): language (language),isOnline(isOnline ),noWords(noWords)
{
for (int i = 0; i < 100; i++){
this->v[i] = (w==NULL)?word():*w;
}
}
};

Error: Expression must have a class type? Trouble with Class Member Function

I'm a fairly novice programmer, and I'm having a bit of trouble sorting through this error. While trying to implement the "formatReportLine()" function near the end of main, this error pops up:
"2 IntelliSense: expression must have class type"
main.cpp
int main()
{
const string FILENAME("books.txt");
ifstream input(FILENAME);
if( input.good() )
{
while( !input.eof() )
{
string name;
int type;
int pages;
float ounces;
getline( input, name );
input >> type >> pages >> ounces;
input.ignore(INT_MAX, '\n');
Book newBook( const string& name, Type type, int pages, float ounces );
cout << newBook.formatReportLine() << endl; //Difficulty with this line
}
}
else
{
cout << "File not found: " << FILENAME << endl;
}
return 0;
}
Here is Book.cpp:
//Constructor
Book::Book( const string& name, Type type, int pages, float ounces )
{
bName = static_cast<string>(name);
bType = type;
bPages = pages;
bOunces = ounces;
cout << "The constructor is running" << endl;
}
//Default Constructor
Book::Book() {
bName = "";
bType = UNKNOWN;
bPages = 0;
bOunces = 0.0f;
}
float Book::getWeightLbs()
{
const float OUNCES = 16.0f;
return bOunces / OUNCES;
}
string Book::getTypeName()
{
return TYPE_WORDS[bType];
}
string Book::formatReportLine()
{
stringstream reportLine;
reportLine << Book::getName() << setw(5) << "| Type: " << Book::getTypeName() << setw(5) << "Pages: "
<< Book::getPages() << setw(5) << "Weight (lbs): " << Book::getWeightLbs();
string newReportLine;
reportLine >> newReportLine;
return newReportLine;
}
And finally book.h
using namespace std;
enum Type
{
UNKNOWN = -1,
PAPERBACK,
HARDBACK
};
const string TYPE_WORDS[] = { "Paperback", "Hardback" };
class Book
{
public:
Book();
//constructor
Book( const string& name, Type type, int pages, float ounces );
//destructor
~Book(){};
string formatReportLine();
float getWeightLbs();
string getTypeName();
//accessors
string getName(){ return bName; };
Type getType(){ return bType; };
int getPages(){ return bPages; };
float getOunces(){ return bOunces; };
private:
string bName;
Type bType;
int bPages;
float bOunces;
};
Any help would be greatly appreciated. Thank you.