Ok так вот мой код:«&» недопустимая операция по ошибке выражения оценки функции члена
#include "driver.h"
#include "stdafx.h"
#include "Book.h"
#include "Author.h"
#include <vector>
void displayBooks(const vector<Book>& books)
{
// students need to write the code for this function
for (int i = 0; i < &books.size; i++)
{
std::cout << &books[i] << std::endl;
}
}
int main()
{
// create a vector for storing the account objects
vector<Book> myBooks;
// create three Author objects
Author p1("J.K.Rowling", "Edinburgh, Scotland");
Author p2("Suzanne Collins", "Connecticut, USA");
Author p3("J.R.R. Tolkien", "Bournmouth, England");
// Create three Book objects
Book b1(p1, "Harry Potter and the Sorcerer's Stone", 256, 24.95);
Book b2(p2, "Mockingjay", 400, 12.99);
Book b3(p3, "The Hobbit", 322, 14.29);
// add the books to the vector
myBooks.push_back(b1);
myBooks.push_back(b2);
myBooks.push_back(b3);
// call the displayBooks function to display the books
displayBooks(myBooks);
cout << "\n\n";
system("PAUSE");
return 0;
}
Верхняя часть это то, что вызывает у меня тревогу, функция displayBooks. Я продолжаю получать '&' Неверная операция над выражением функции связанного члена Ошибка. Как это исправить?
Кажется, вам нужно найти [хорошую книгу для начинающих] (http://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list) и начать все заново. –
'i