3 Replies - 233 Views - Last Post: 14 November 2012 - 11:19 AM Rate Topic: -----

#1 zethulon  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 28
  • Joined: 25-September 12

Error: member class function not declared error, albeit declared

Posted 14 November 2012 - 08:31 AM

This is the error I am getting:

C:\Dev-Cpp\book.cpp no `void bookinfo::newbook(bookinfo&, std::string, std::string, std::string, std::string, std::string, std::string)' member function declared in class `bookinfo'

book.cpp
#ifndef __book_h__
#define __book_h__
#include <string>
using namespace std;

class bookinfo
{
  public:
  void newbook(bookinfo & book, string number, string lastname,
               string firstname, string title, string genre,
               string availability);
  string getlastname();
  string getfirstname();
  string getcatnumber();
  string getbooktitle();
  string getgenre();
  string getavailability();
  
  private:
  string catalognumber;
  string authorlname;
  string authorfname;
  string booktitle;
  string genre;
  string availability;
};

#endif



book.cpp
#include "book.h"


 void bookinfo::newbook(bookinfo & book, string number, string lastname,
             string firstname, string title, string genre,
             string availability)
{
  book.catalognumber = number;
  book.authorfname = lastname;
  book.authorlname = firstname;
  book.booktitle = title;
  book.genre = genre;
  book.availability = availability;
}



Is This A Good Question/Topic? 0
  • +

Replies To: Error: member class function not declared error, albeit declared

#2 Xupicor  Icon User is offline

  • Nasal Demon
  • member icon

Reputation: 249
  • View blog
  • Posts: 582
  • Joined: 31-May 11

Re: Error: member class function not declared error, albeit declared

Posted 14 November 2012 - 08:56 AM

Compiles fine here on g++ 4.7.2. So either your compiler is acting up (DevC++ is an old IDE, and by default uses preinstalled oooold version of MinGW), or there's some other issue.


Also, don't put using namespace std; in global scope in header files. Just don't - it can end up with hard to debug, name-resolving related, (at worst case) "science fiction" bugs.
Was This Post Helpful? 1
  • +
  • -

#3 zethulon  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 28
  • Joined: 25-September 12

Re: Error: member class function not declared error, albeit declared

Posted 14 November 2012 - 09:21 AM

View PostXupicor, on 14 November 2012 - 08:56 AM, said:

Compiles fine here on g++ 4.7.2. So either your compiler is acting up (DevC++ is an old IDE, and by default uses preinstalled oooold version of MinGW), or there's some other issue.


Also, don't put using namespace std; in global scope in header files. Just don't - it can end up with hard to debug, name-resolving related, (at worst case) "science fiction" bugs.


What compiler would you recommend?
Was This Post Helpful? 0
  • +
  • -

#4 vividexstance  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 662
  • View blog
  • Posts: 2,273
  • Joined: 31-December 10

Re: Error: member class function not declared error, albeit declared

Posted 14 November 2012 - 11:19 AM

It depends on the OS (Operating System) you're running. GCC (GNU Compiler Collection) is probably the most widely used compiler. You can use it on Windows, but most people running Windows use Microsoft Visual Studio because it's not just a compiler, but a full-fledged IDE (Integrate Development Environment). You don't need an IDE but it definitely helps when you're a beginner.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1