main.cpp: In function âint main()â:
main.cpp:12: error: request for member âdispBookâ in âbook1â, which is of non-class type âBook ()()â
and I cant not find out for the life of me why. I beleive I have all my -> correct so that shouldnt be the problem. Here is my code:
lab04.cpp
#include"lab04.h"
Book::Book()
{
title = "";
author = "unknown";
int price = 795;
genre = 0;
status = false;
}
Book::Book(string title, int price)
{
this->title = title;
this->price = price;
author = "unknown";
genre = 0;
status = false;
}
void Book::dispBook(void) const
{
cout.setf(ios::fixed | ios::showpoint);
cout.precision(2);
cout << "Title : \"" << title << "\"\n"
<< "Author : \"" << author << "\"\n"
<< "Price : $" << price / 100.0 << endl
<< "Genre : " << genre
<< "In stock? " << (status ? "yes" : "no")
<< endl;
return;
}
main.cpp
#include<iostream>
#include<string>
#include"lab04.h"
using namespace std;
int main()
{
string title = "The art of Wooting";
int price = 203;
Book book1;
Book book2(title,price);
book1.dispBook();
book2.dispBook();
system("pause");
return 0;
}
Lab04.h
#ifndef LAB04_H
#define LAB04_H
#include<iostream>
#include<string>
using namespace std;
class Book
{
public:
Book();
Book(string,int);
void dispBook(void) const;
private:
string title;
string author;
int price;
int genre;
bool status;
};
#endif
any help is greatly appreciated as im starting to get sore eyes lol Thanks!

New Topic/Question
Reply




MultiQuote







|