Thread: Need Help....!!!

  1. #1

    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 {
    int PassBookId;
    int age;
    float balance;
    char name;
    void set_values (int a, int b, float c);
    { PassBookId=a; age=b; balance=c;}

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

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

    int main () {

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

    return 0;

    thanks very much.....

  2. #2
    Registered User
    Join Date
    Aug 2001
    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
    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.

    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed