Problem: expected `,' or `...' before '&' token

This is a discussion on Problem: expected `,' or `...' before '&' token within the C++ Programming forums, part of the General Programming Boards category; i have to classes, the Order class is in Order.h and the ISBN class is in ISBN.h Order.h: Code: #include ...

  1. #1
    Registered User
    Join Date
    Oct 2007
    Posts
    118

    Problem: expected `,' or `...' before '&' token

    i have to classes, the Order class is in Order.h and the ISBN class is in ISBN.h

    Order.h:
    Code:
    #include <cstdio>
    #include <cstring>
    #include <iostream>
    using namespace std;
    class ISBN;
    class Order{
      char s;
      int ordered;
      int delivered;
      char ISBN[11];
     public:
      Order();
      Order(const ISBN& isbn); <- here is says expected `,' or `...' before '&' token  ISO C++ forbids declaration of `ISBN' with no type
      void style(char c);
      int has(const ISBN& isbn) const; <- here is says expected `,' or `...' before '&' token  ISO C++ forbids declaration of `ISBN' with no type
      int onOrder() const; 
      int augment(istream& is); 
      int augment(int add); 
      int recieve(istream& is); 
      void display(ostream& os) const; 
    };
    ISBN.h
    Code:
    #include <cstdio>
    #include <cstring>
    #include <iostream>
    using namespace std;
    class ISBNPrefix;
    class ISBN{
      char ISBN1[11];
      char area[6];
      char publisher[8];
      char title[8];
      char s;
      int isRegistered;
      int decode(const ISBNPrefix& list);
     public:
      ISBN(); 
      ISBN(const char* str, const ISBNPrefix& list);
      ~ISBN();
      void style(char c);
      int empty() const;
      int registered() const;
      void toStr(char* isbn) const;
      void toStrWithStyle(char* isbn) const;
      int accept(istream& is, const ISBNPrefix& list); /* not */
      friend int operator==(const ISBN& left, const ISBN& right); /* not */  
    };
    any ideas what caused this?

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    23,630
    I believe the problem is here:
    Code:
    char ISBN[11];
    You gave a member variable the same name as a class.

    By the way, do not place using directives at global scope in a header file. They will cause namespace pollution.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Oct 2007
    Posts
    118
    Quote Originally Posted by laserlight View Post
    I believe the problem is here:
    Code:
    char ISBN[11];
    You gave a member variable the same name as a class.

    By the way, do not place using directives at global scope in a header file. They will cause namespace pollution.
    alright, thanks i fixed both problems

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. expected primary-expression before xxx token
    By lehe in forum C++ Programming
    Replies: 5
    Last Post: 07-06-2009, 02:54 PM
  2. Problem with simple C programming
    By YAV in forum C Programming
    Replies: 2
    Last Post: 11-17-2008, 09:29 AM
  3. Replies: 2
    Last Post: 04-26-2008, 04:43 AM
  4. expected primary expansion before ')' token.
    By agent d00nut in forum C++ Programming
    Replies: 10
    Last Post: 11-06-2005, 04:54 AM
  5. Bin packing problem....
    By 81N4RY_DR460N in forum C++ Programming
    Replies: 0
    Last Post: 08-01-2005, 05:20 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21