HI, little help requested.
i am trying to select the members of a class object b1[i], by comparing
a member->value with and external value, and if the comparision is
true, then I would assign the entire b1[i] object to b2[i] object, after creating
a new book().
However I keep getting this error
Code:
main.cxx: In function `int main(int, char**)':
main.cxx:107: error: no matching function for call to `book::setValues(book*&)'
book.h:15: error: candidates are: void book::setValues(book**)
book.h:17: error: void book::setValues(std::basic_string<char,
std::char_traits<char>, std::allocator<char> >, std::basic_string<char,
std::char_traits<char>, std::allocator<char> >, std::basic_string<char,
std::char_traits<char>, std::allocator<char> >, std::basic_string<char,
std::char_traits<char>, std::allocator<char> >, std::basic_string<char,
std::char_traits<char>, std::allocator<char> >, float)
make: *** [main.o] Error 1
Im not sure if its the way im calling my constructor for this member function, becuase i havent used the & operator, only the ** types. Any help or suggestions are greatly appreciated.
main.cpp
Code:
float low,high;
int nsize = 0;
book *b2[VAL];
for(int i = 0; i < size-1; i++) {
if(b1[i]->getPrice() > low && b1[i]->getPrice() < high) {
b2[i] = new book(title, author, publisher, month, year, price);
b2[i]->setValues(b1[i]); // this line is causing ERROR.
nsize++;
}
book.h
Code:
#include <string>
#include <fstream>
using namespace std;
class book {
public:
book(string,string,string,string,string,float);
~book();
string getTitle() { return title; }
string getAuthor() { return author; }
string getPublisher() { return publisher; }
string getMonth() { return month; }
string getYear() { return year; }
void setValues(book **b){}
void setValues(string title, string author, string publisher,
string month, string year, float price);
float getPrice() { return price; }
private:
string title;
string author;
string publisher;
string month;
string year;
float price;
};
book.cpp
Code:
#include "book.h"
#include <iostream>
#include <string>
using namespace std;
book::book( string title, string author, string publisher,
string month, string year, float price) {}
void book::setValues(string title, string author, string publisher,
string month, string year, float price) {
this->title=title; this->author=author; this->publisher=publisher;
this->month=month; this->year=year; this->price=price;
}
void book::setValues(book **b) {
b->title=this->title; b->author=this->author; b->publisher=this->publisher;
b->month=this->month; b->year=this->year; b->price=this->price;
}