Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

I'm learning C++, plz help

Name: Aurath 2006-12-04 22:18

So i'm learning c++. I know its a horrible language but I need to learn it for several reasons that have nothing to do with the body of this post.
I've got a big project due tomorrow so I would appreciate help before noon tomorrow if at all possible (its 7pm here).
Anyway...
Ive got a .h file that holds the list of function declarations. One of said functions takes the class "Book" that I wrote and is contained in Book.cpp and Book.h. The function declaration that I'm having trouble with is simply this:
void print(Book);

Why does it not recognize "Book" as an identifier? I included Book.h and it recognizes it from all the .cpp files that i'm using. What arcane peice of c++ am I missing that requires different class identifier handling in .h files than .cpp?
My life is in your hands. Please help.

Name: Anonymous 2006-12-04 23:28

are you including book.h in just the driver or is it also at the top of the function declaration .h file too? should be both.

Name: Anonymous 2006-12-04 23:29

paste the exact error message and the exact code that causes it

Name: Anonymous 2006-12-05 14:22

you need a function variable to use with it, try
print(Book myBook);

In the function the variable you use is myBook, of the class Book.

Personally, i think C++ is a wonderful language. But it's a matter of taste as well, but yeah, it can definately be improved.

Name: Anonymous 2006-12-06 0:22

Instantiate?

Name: Anonymous 2006-12-08 23:28

My too late guess: the definition of book hasn't happened before the compiler is trying to define the print function.

Name: Anonymous 2006-12-09 6:56

// File Book.h:
#ifndef BOOK_H
#define BOOK_H

class Book {};

#endif // BOOK_H

// File to print the Book:
#include "Book.h"

void print(const Book& b) // USE A REFERENCE!!!
{
     // use your book here
}

Name: Anonymous 2006-12-14 15:52

FOOK you, PISS ANT MOTHER FUCKER C++ OWNZ YOUR SOUL C++ FTW FUCK YOU KICK YOUR ASS WITH C++

Name: Anonymous 2009-01-14 13:32

No

Name: Anonymous 2009-03-06 7:56

The truth is that   if your keyboard   D You are   paid by someone   else who likes   to be anal   penetrated by another   versed in the   progress of the   tubes and it   will go away   or want to   deal with modern.

Name: Anonymous 2011-02-03 4:06

Name: Sgt.Kabu텅kiman⋰ꂔ 2012-05-28 21:07

Bringing /prog/ back to its people
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List