Thread: Need Help....!!!

  1. #1
    Unregistered
    Guest

    Post Need Help....!!!

    i seem to have difficulty in identifying what is the error in my program.....

    #include <iostream.h>
    #include <conio.h>

    class PassBook {
    protected:
    int PassBookId;
    int age;
    float balance;
    char name;
    public:
    void set_values (int a, int b, float c);
    { PassBookId=a; age=b; balance=c;}
    };

    class Costumer: public PassBook {
    public:
    int value (void)
    { return (name, age); }
    };

    class AccountDetails: public PassBook {
    public:
    int value (void)
    { return (balance); }
    };

    int main () {
    clrscr();

    Costumer cost;
    AccountDetails ad;
    cost.set_values (peter, 34)
    ad.set_values (40000)
    cout << cost.value() << endl;
    cout << ad.value() << endl;

    getch();
    return 0;
    }


    thanks very much.....

  2. #2
    Registered User
    Join Date
    Aug 2001
    Posts
    52
    Tell me what you are trying to do and what your program is not doing for you.

    I dont see your constructors and return only returns one value.

  3. #3
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    Ignoring the simple syntax errors:
    ad.set_values (40000);
    set_values takes three arguments, you only pass it one.

    cost.set_values (peter, 34);
    What is peter? This variable is undefined and set_values doesn't take two arguments, it takes three.

    int value (void)
    You're returning a float, declare the return type as float

    return (name, age);
    This won't work as expected

    I get the feeling that you were trying to use set_values as if it were overloaded in your derived classes. If you don't overload the method in your derived class then objects of that class will use the method inherited from the base class.

    -Prelude
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed