Extremely Simple Code, Please Help With ERRORS......
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Thread: Extremely Simple Code, Please Help With ERRORS......

  1. #1
    Join Date
    Nov 2012
    Posts
    8

    Extremely Simple Code, Please Help With ERRORS......

    class Book
    {
    int BNo;
    char BName[80];
    char BAuth[80];
    unsigned int Bcop;
    public:
    void BInput()
    {
    cout<<"Book Number: ";cin>>Bno;//Error 1
    cout<<"Book Name: ";gets(Bname);
    cout<<"Book Author: ";gets(BAuth);
    }
    void BDisp()
    {
    cout<<"Book Number: "<<Bno<<endl;
    cout<<"Book Name: ";puts(Bname);
    cout<<"Book Author: ";puts(BAuth);
    }
    int BGet_Bno() {return Bno;}
    char* BGet_BName() {return &BName;}//Error 2
    char* BGet_BAuth() {return &BAuth;}
    };



    Upon compilation, I am getting multiple errors as:
    Error 1:Undefine Symbol Bno
    Error 2: Cannot convert char[80] * to char *

    Please help me out!!

  2. #2
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Posts
    11,986

    Re: Extremely Simple Code, Please Help With ERRORS......

    C++ is a case-sensitive language.

  3. #3
    Join Date
    Nov 2012
    Posts
    8

    Re: Extremely Simple Code, Please Help With ERRORS......

    Thanks a TON for correcting that MOST RIDICULOUS MISTAKE EVER!!
    Can you please tell about Error 2 as well?
    I am a newbie to this stuff.....

  4. #4
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Posts
    11,986

    Re: Extremely Simple Code, Please Help With ERRORS......

    If you just refer to an array by name, it is essentially a pointer. So return BName, not &BName.

  5. #5
    Join Date
    Nov 2012
    Posts
    8

    Re: Extremely Simple Code, Please Help With ERRORS......

    That solved the problem...
    Thanks a lot again.....
    Its nice to have people like you around....

  6. #6
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Posts
    11,986

    Re: Extremely Simple Code, Please Help With ERRORS......

    Quote Originally Posted by aditya.manglik View Post
    That solved the problem...
    Thanks a lot again.....
    Its nice to have people like you around....
    You're welcome.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center