1. Welcome to Tacoma World!

    You are currently viewing as a guest! To get full-access, you need to register for a FREE account.

    As a registered member, you’ll be able to:
    • Participate in all Tacoma discussion topics
    • Communicate privately with other Tacoma owners from around the world
    • Post your own photos in our Members Gallery
    • Access all special features of the site

C++ Assignment help

Discussion in 'Technology' started by tarheelfan_08, Feb 15, 2010.

  1. Feb 15, 2010 at 8:27 PM
    #21
    tarheelfan_08

    tarheelfan_08 [OP] Carolina Alliance

    Joined:
    Jan 4, 2008
    Member:
    #4098
    Messages:
    2,944
    Gender:
    Male
    First Name:
    Justin
    North Carolina
    Vehicle:
    2010 White 4x4 Double Cab Tacoma Short Bed
    Chrome Grill, Chrome accessories(door handles and mirror covers), LEER Super White Cover, Mirrors with Turn Signals, Window Vent Visors, Step Rails, WeatherTech Digital Floor Mats, Mini Maglight Holder, Chrome Bull Bar

    checking and savings are defined in my customer class!
     
  2. Feb 15, 2010 at 8:33 PM
    #22
    tarheelfan_08

    tarheelfan_08 [OP] Carolina Alliance

    Joined:
    Jan 4, 2008
    Member:
    #4098
    Messages:
    2,944
    Gender:
    Male
    First Name:
    Justin
    North Carolina
    Vehicle:
    2010 White 4x4 Double Cab Tacoma Short Bed
    Chrome Grill, Chrome accessories(door handles and mirror covers), LEER Super White Cover, Mirrors with Turn Signals, Window Vent Visors, Step Rails, WeatherTech Digital Floor Mats, Mini Maglight Holder, Chrome Bull Bar
    He gave it as a 2 day project!

    Code:
    #ifndef ACCOUNT_H
    #define ACCOUNT_H
    
    #include "Customer.h"
    
    //Account Class
    class Account {
    private:
            Customer myCustomer[2];
            string type;
            int number;
            double balance;
            double rate;
            double savings;
            double checking;
            double intrest;
            double NewBalance;
    
    public:
            Account(); // Constructor
            Account(string, int, double, double) ;
                    void setType(string);
                    void setNumber(int);
                    void setBalance(double);
                    void setRate(double);
    
                    string getType();
                    int getNumber();
                    double getBalance();
                    double getRate();
                    Customer& getCustomer ( int );
                    void valid_rate(double);
                    void ApplyInterest();
                    void operator += (Account&);
                    void operator -= (Account&);
                    void operator ++ (int);
                    };       
    //-----------------------------------------------------------------------------
    //class definition
            Account::Account() {
                    type = " ";
                    number = 0;
                    balance = 0;
                    rate = 0;
            }
    
            Account::Account(string type, int number, double balance, double rate) {
                    Account::type = type;
                    Account::number = number;
                    Account::balance = balance;
                    valid_rate(rate);
                    }
    void Account::setType(string type) {
        Account::type = type;
    }
    
    void Account::setNumber(int number) {
        Account::number = number;
    }
    
    void Account::setBalance(double balance) {
        Account::balance = balance;
    }
    
    void Account::setRate(double rate) {
            valid_rate(rate);
    }
    
    string Account::getType() {
        return type;
    }
    int Account::getNumber() {
        return number;
    }
    double Account::getBalance() {
        return balance;
    }
    double Account::getRate() {
        return rate;
    }
    
    void Account::valid_rate(double rate) {
            if (rate >=.01 && rate <= .1)
                    Account::rate=rate;
            else {
                    Account::rate=0;
                    cout << "WARNING! You have entered an invalid rate!\n";
            }
    }
    
    void Account::ApplyInterest() {
                    intrest = rate * balance;
                    NewBalance = intrest + balance;
                    cout << "The amount of intrest for the Customer is: $" << intrest << " and the account balance is: $" << NewBalance << ".\n";
    }       
    
    
    Customer& Account::getCustomer(int n) {
            return myCustomer[n];
    }
    
        void operator += (Account& a) {
            a.setBalance(a.getBalance()+ a.getBalance());
        }
    
        void operator -= (Account& a) {
            a.setBalance(a.getBalance() - a.getBalance());
        }
    //MOST OF THE LEFT ERRORS ARE HERE--------------------------------------
        void operator ++ (int n) {
                    Customer::balance(Customer::savings + Customer::checking);
        }
    
    #endif
    
    1>------ Build started: Project: Test1, Configuration: Debug Win32 ------
    1> Test1.cpp
    1>\account.h(102): error C2805: binary 'operator +=' has too few parameters
    1>\account.h(106): error C2805: binary 'operator -=' has too few parameters
    1>\account.h(110): error C2803: 'operator ++' must have at least one formal parameter of class type
    1>\account.h(111): error C2597: illegal reference to non-static member 'Customer::balance'
    1>\account.h(111): error C2597: illegal reference to non-static member 'Customer::savings'
    1>\account.h(111): error C3867: 'Customer::savings': function call missing argument list; use '&Customer::savings' to create a pointer to member
    1>\account.h(111): error C2597: illegal reference to non-static member 'Customer::checking'
    1>\account.h(111): error C3867: 'Customer::checking': function call missing argument list; use '&Customer::checking' to create a pointer to member
    1>\account.h(111): error C2568: '+' : unable to resolve function overload
    1> unable to recover from previous error(s); stopping compilation
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
     
  3. Feb 15, 2010 at 8:34 PM
    #23
    NetMonkey

    NetMonkey Well-Known Member

    Joined:
    Aug 14, 2008
    Member:
    #8536
    Messages:
    1,734
    Gender:
    Male
    Geogetown, TX
    Vehicle:
    2010, 4x4, DC, off-road, shortbed, automatic
    Toytec Ultimate Lift @ 3", Mickey Thompson MTZ's 285/75/16, Moto Metal 955b, rear 2" ALL, Marlin Crawler sliders
    then you have an issue with variable scope.

    the Account class cannot access private variables in your Customer class.

    a solution here would be to query checking and savings from the get functions you wrote in the Customer class.

    for example:

    Code:
     
        void operator ++ (int n, ) {
           int temp_savings = Customer::getSavings();
           int temp_checking = Customer::getChecking();
           Account::setBalance(temp_savings  +  temp_checking);
        } 
    
     
  4. Feb 15, 2010 at 8:41 PM
    #24
    NetMonkey

    NetMonkey Well-Known Member

    Joined:
    Aug 14, 2008
    Member:
    #8536
    Messages:
    1,734
    Gender:
    Male
    Geogetown, TX
    Vehicle:
    2010, 4x4, DC, off-road, shortbed, automatic
    Toytec Ultimate Lift @ 3", Mickey Thompson MTZ's 285/75/16, Moto Metal 955b, rear 2" ALL, Marlin Crawler sliders
    is this a college class? have you had a C++ class before? is this a beginning C++ class or an object oriented C++ class?
     
  5. Feb 15, 2010 at 8:44 PM
    #25
    NetMonkey

    NetMonkey Well-Known Member

    Joined:
    Aug 14, 2008
    Member:
    #8536
    Messages:
    1,734
    Gender:
    Male
    Geogetown, TX
    Vehicle:
    2010, 4x4, DC, off-road, shortbed, automatic
    Toytec Ultimate Lift @ 3", Mickey Thompson MTZ's 285/75/16, Moto Metal 955b, rear 2" ALL, Marlin Crawler sliders
    ohh... these need to be defined like this:

    Code:
     
        void [B]Account::[/B]operator += (Account& a) {
            a.setBalance(a.getBalance()+ a.getBalance());
        }
        void [B]Account::[/B]operator -= (Account& a) {
            a.setBalance(a.getBalance() - a.getBalance());
        }
    
        void [B]Account::[/B]operator ++ (int n) {
                    Customer::balance(Customer::savings + Customer::checking);
        }
    
     
  6. Feb 15, 2010 at 8:47 PM
    #26
    tarheelfan_08

    tarheelfan_08 [OP] Carolina Alliance

    Joined:
    Jan 4, 2008
    Member:
    #4098
    Messages:
    2,944
    Gender:
    Male
    First Name:
    Justin
    North Carolina
    Vehicle:
    2010 White 4x4 Double Cab Tacoma Short Bed
    Chrome Grill, Chrome accessories(door handles and mirror covers), LEER Super White Cover, Mirrors with Turn Signals, Window Vent Visors, Step Rails, WeatherTech Digital Floor Mats, Mini Maglight Holder, Chrome Bull Bar
    It is a college class and its supposed to be the advanced...but the teacher for the first class and this one are different and my first teacher was horrible!

    Code:
    #ifndef ACCOUNT_H
    #define ACCOUNT_H
    
    #include "Customer.h"
    
    //Account Class
    class Account {
    private:
            Customer myCustomer[2];
            string type;
            int number;
            double balance;
            double rate;
    
            double intrest;
            double NewBalance;
    
    public:
            Account(); // Constructor
            Account(string, int, double, double) ;
                    void setType(string);
                    void setNumber(int);
                    void setBalance(double);
                    void setRate(double);
    
                    string getType();
                    int getNumber();
                    double getBalance();
                    double getRate();
                    Customer& getCustomer ( int );
                    void valid_rate(double);
                    void ApplyInterest();
                    void operator += (Account&);
                    void operator -= (Account&);
                    void operator ++ (int);
                    };       
    //-----------------------------------------------------------------------------
    //class definition
            Account::Account() {
                    type = " ";
                    number = 0;
                    balance = 0;
                    rate = 0;
            }
    
            Account::Account(string type, int number, double balance, double rate) {
                    Account::type = type;
                    Account::number = number;
                    Account::balance = balance;
                    valid_rate(rate);
                    }
    void Account::setType(string type) {
        Account::type = type;
    }
    
    void Account::setNumber(int number) {
        Account::number = number;
    }
    
    void Account::setBalance(double balance) {
        Account::balance = balance;
    }
    
    void Account::setRate(double rate) {
            valid_rate(rate);
    }
    
    string Account::getType() {
        return type;
    }
    int Account::getNumber() {
        return number;
    }
    double Account::getBalance() {
        return balance;
    }
    double Account::getRate() {
        return rate;
    }
    
    void Account::valid_rate(double rate) {
            if (rate >=.01 && rate <= .1)
                    Account::rate=rate;
            else {
                    Account::rate=0;
                    cout << "WARNING! You have entered an invalid rate!\n";
            }
    }
    
    void Account::ApplyInterest() {
                    intrest = rate * balance;
                    NewBalance = intrest + balance;
                    cout << "The amount of intrest for the Customer is: $" << intrest << " and the account balance is: $" << NewBalance << ".\n";
    }       
    
    
    Customer& Account::getCustomer(int n) {
            return myCustomer[n];
    }
    
    void Account::operator += (Account& a) {
            a.setBalance(a.getBalance()+ a.getBalance());
        }
        void Account::operator -= (Account& a) {
            a.setBalance(a.getBalance() - a.getBalance());
        }
    
        void operator ++ (int n) {
               int temp_savings = Customer::getSavings();
               int temp_checking = Customer::getChecking();
               Account::setBalance(temp_savings  +  temp_checking);
            }
    
    #endif
    
    1>------ Build started: Project: Test1, Configuration: Debug Win32 ------
    1> Test1.cpp
    1>\account.h(108): error C2803: 'operator ++' must have at least one formal parameter of class type
    1>\account.h(109): error C2352: 'Customer::getSavings' : illegal call of non-static member function
    1> \customer.h(40) : see declaration of 'Customer::getSavings'
    1>\account.h(110): error C2352: 'Customer::getChecking' : illegal call of non-static member function
    1> \customer.h(41) : see declaration of 'Customer::getChecking'
    1>\account.h(111): error C2352: 'Account::setBalance' : illegal call of non-static member function
    1> \account.h(23) : see declaration of 'Account::setBalance'
    1>\date.h(32): fatal error C1070: mismatched #if/#endif pair in file '\date.h'
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
     
  7. Feb 15, 2010 at 8:52 PM
    #27
    NetMonkey

    NetMonkey Well-Known Member

    Joined:
    Aug 14, 2008
    Member:
    #8536
    Messages:
    1,734
    Gender:
    Male
    Geogetown, TX
    Vehicle:
    2010, 4x4, DC, off-road, shortbed, automatic
    Toytec Ultimate Lift @ 3", Mickey Thompson MTZ's 285/75/16, Moto Metal 955b, rear 2" ALL, Marlin Crawler sliders
    looking at it again, i think the logic on your ++ function isnt quite right.
    i think you need to pass in a customer to that function and perform the operations on that variable.

    Code:
     
        void operator ++ (Customer& customer) {
               int temp_savings = customer::getSavings();
               int temp_checking = customer::getChecking();
               Account::setBalance(temp_savings  +  temp_checking);
            }
    
    
     
  8. Feb 15, 2010 at 9:01 PM
    #28
    tarheelfan_08

    tarheelfan_08 [OP] Carolina Alliance

    Joined:
    Jan 4, 2008
    Member:
    #4098
    Messages:
    2,944
    Gender:
    Male
    First Name:
    Justin
    North Carolina
    Vehicle:
    2010 White 4x4 Double Cab Tacoma Short Bed
    Chrome Grill, Chrome accessories(door handles and mirror covers), LEER Super White Cover, Mirrors with Turn Signals, Window Vent Visors, Step Rails, WeatherTech Digital Floor Mats, Mini Maglight Holder, Chrome Bull Bar
    I get the same errors!
     
  9. Feb 15, 2010 at 9:04 PM
    #29
    NetMonkey

    NetMonkey Well-Known Member

    Joined:
    Aug 14, 2008
    Member:
    #8536
    Messages:
    1,734
    Gender:
    Male
    Geogetown, TX
    Vehicle:
    2010, 4x4, DC, off-road, shortbed, automatic
    Toytec Ultimate Lift @ 3", Mickey Thompson MTZ's 285/75/16, Moto Metal 955b, rear 2" ALL, Marlin Crawler sliders
    fix this:

    1>\date.h(32): fatal error C1070: mismatched #if/#endif pair in file '\date.h'
     
  10. Feb 15, 2010 at 9:08 PM
    #30
    tarheelfan_08

    tarheelfan_08 [OP] Carolina Alliance

    Joined:
    Jan 4, 2008
    Member:
    #4098
    Messages:
    2,944
    Gender:
    Male
    First Name:
    Justin
    North Carolina
    Vehicle:
    2010 White 4x4 Double Cab Tacoma Short Bed
    Chrome Grill, Chrome accessories(door handles and mirror covers), LEER Super White Cover, Mirrors with Turn Signals, Window Vent Visors, Step Rails, WeatherTech Digital Floor Mats, Mini Maglight Holder, Chrome Bull Bar
    Code:
    #ifndef ACCOUNT_H
    #define ACCOUNT_H
    
    #include "Customer.h"
    
    //Account Class
    class Account {
    private:
            Customer myCustomer[2];
            string type;
            int number;
            double balance;
            double rate;
    
            double intrest;
            double NewBalance;
    
    public:
            Account(); // Constructor
            Account(string, int, double, double) ;
                    void setType(string);
                    void setNumber(int);
                    void setBalance(double);
                    void setRate(double);
    
                    string getType();
                    int getNumber();
                    double getBalance();
                    double getRate();
                    Customer& getCustomer ( int );
                    void valid_rate(double);
                    void ApplyInterest();
                    void operator += (Account&);
                    void operator -= (Account&);
                    void operator ++ (int);
                    };       
    //-----------------------------------------------------------------------------
    //class definition
            Account::Account() {
                    type = " ";
                    number = 0;
                    balance = 0;
                    rate = 0;
            }
    
            Account::Account(string type, int number, double balance, double rate) {
                    Account::type = type;
                    Account::number = number;
                    Account::balance = balance;
                    valid_rate(rate);
                    }
    void Account::setType(string type) {
        Account::type = type;
    }
    
    void Account::setNumber(int number) {
        Account::number = number;
    }
    
    void Account::setBalance(double balance) {
        Account::balance = balance;
    }
    
    void Account::setRate(double rate) {
            valid_rate(rate);
    }
    
    string Account::getType() {
        return type;
    }
    int Account::getNumber() {
        return number;
    }
    double Account::getBalance() {
        return balance;
    }
    double Account::getRate() {
        return rate;
    }
    
    void Account::valid_rate(double rate) {
            if (rate >=.01 && rate <= .1)
                    Account::rate=rate;
            else {
                    Account::rate=0;
                    cout << "WARNING! You have entered an invalid rate!\n";
            }
    }
    
    void Account::ApplyInterest() {
                    intrest = rate * balance;
                    NewBalance = intrest + balance;
                    cout << "The amount of intrest for the Customer is: $" << intrest << " and the account balance is: $" << NewBalance << ".\n";
    }       
    
    
    Customer& Account::getCustomer(int n) {
            return myCustomer[n];
    }
    
    void Account::operator += (Account& a) {
            a.setBalance(a.getBalance()+ a.getBalance());
        }
        void Account::operator -= (Account& a) {
            a.setBalance(a.getBalance() - a.getBalance());
        }
    
        void operator ++ (int n) {
               int temp_savings = Customer::getSavings();
               int temp_checking = Customer::getChecking();
               Account::setBalance(temp_savings  +  temp_checking);
            }
    
    #endif
    
    1>------ Build started: Project: Test1, Configuration: Debug Win32 ------
    1> Test1.cpp
    1>\account.h(108): error C2803: 'operator ++' must have at least one formal parameter of class type
    1>\account.h(109): error C2352: 'Customer::getSavings' : illegal call of non-static member function
    1> \customer.h(40) : see declaration of 'Customer::getSavings'
    1>\account.h(110): error C2352: 'Customer::getChecking' : illegal call of non-static member function
    1> \customer.h(41) : see declaration of 'Customer::getChecking'
    1>\account.h(111): error C2352: 'Account::setBalance' : illegal call of non-static member function
    1> \account.h(23) : see declaration of 'Account::setBalance'
    1>\test1.cpp(5): error C2143: syntax error : missing ';' before 'using'
    1>\test1.cpp(28): error C2039: 'getDate' : is not a member of 'Account'
    1> \account.h(7) : see declaration of 'Account'
    1>\test1.cpp(28): error C2228: left of '.setDate' must have class/struct/union
    1>\test1.cpp(40): error C2660: 'Account::getRate' : function does not take 1 arguments
    1>\test1.cpp(40): error C2228: left of '.setRate' must have class/struct/union
    1>\test1.cpp(51): error C2676: binary '[' : 'Account' does not define this operator or a conversion to a type acceptable to the predefined operator
    1>\test1.cpp(51): error C2228: left of '.displayCustomer' must have class/struct/union
    1>\test1.cpp(56): error C2676: binary '[' : 'Account' does not define this operator or a conversion to a type acceptable to the predefined operator
    1>\test1.cpp(56): error C2228: left of '.ApplyIntrest' must have class/struct/union
    1>\test1.cpp(62): error C2676: binary '[' : 'Account' does not define this operator or a conversion to a type acceptable to the predefined operator
    1>\test1.cpp(62): error C2228: left of '.displayCustomer' must have class/struct/union
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
     
  11. Feb 15, 2010 at 9:11 PM
    #31
    NetMonkey

    NetMonkey Well-Known Member

    Joined:
    Aug 14, 2008
    Member:
    #8536
    Messages:
    1,734
    Gender:
    Male
    Geogetown, TX
    Vehicle:
    2010, 4x4, DC, off-road, shortbed, automatic
    Toytec Ultimate Lift @ 3", Mickey Thompson MTZ's 285/75/16, Moto Metal 955b, rear 2" ALL, Marlin Crawler sliders
    make these static in both the Account and Customer classes:

    static void setType(string);
    static void setNumber(int);
    static void setBalance(double);
    static void setRate(double);
     
  12. Feb 15, 2010 at 9:13 PM
    #32
    NetMonkey

    NetMonkey Well-Known Member

    Joined:
    Aug 14, 2008
    Member:
    #8536
    Messages:
    1,734
    Gender:
    Male
    Geogetown, TX
    Vehicle:
    2010, 4x4, DC, off-road, shortbed, automatic
    Toytec Ultimate Lift @ 3", Mickey Thompson MTZ's 285/75/16, Moto Metal 955b, rear 2" ALL, Marlin Crawler sliders
    do this:

    Code:
     
      void operator ++ (Customer& customer) {
               int temp_savings = customer::getSavings();
               int temp_checking = customer::getChecking();
               Account::setBalance(temp_savings  +  temp_checking);
            }
    
     
  13. Feb 15, 2010 at 9:15 PM
    #33
    tarheelfan_08

    tarheelfan_08 [OP] Carolina Alliance

    Joined:
    Jan 4, 2008
    Member:
    #4098
    Messages:
    2,944
    Gender:
    Male
    First Name:
    Justin
    North Carolina
    Vehicle:
    2010 White 4x4 Double Cab Tacoma Short Bed
    Chrome Grill, Chrome accessories(door handles and mirror covers), LEER Super White Cover, Mirrors with Turn Signals, Window Vent Visors, Step Rails, WeatherTech Digital Floor Mats, Mini Maglight Holder, Chrome Bull Bar
    Did that and here are my errors!

    1>------ Build started: Project: Test1, Configuration: Debug Win32 ------
    1> Test1.cpp
    1>\account.h(53): error C2597: illegal reference to non-static member 'Account::type'
    1>\account.h(57): error C2597: illegal reference to non-static member 'Account::number'
    1>\account.h(61): error C2597: illegal reference to non-static member 'Account::balance'
    1>\account.h(65): error C2352: 'Account::valid_rate' : illegal call of non-static member function
    1> \account.h(31) : see declaration of 'Account::valid_rate'
    1>\account.h(109): error C2653: 'customer' : is not a class or namespace name
    1>\account.h(109): error C3861: 'getSavings': identifier not found
    1>\account.h(110): error C2653: 'customer' : is not a class or namespace name
    1>\account.h(110): error C3861: 'getChecking': identifier not found
    1>\test1.cpp(5): error C2143: syntax error : missing ';' before 'using'
    1>\test1.cpp(28): error C2039: 'getDate' : is not a member of 'Account'
    1> \account.h(7) : see declaration of 'Account'
    1>\test1.cpp(28): error C2228: left of '.setDate' must have class/struct/union
    1>\test1.cpp(40): error C2660: 'Account::getRate' : function does not take 1 arguments
    1>\test1.cpp(40): error C2228: left of '.setRate' must have class/struct/union
    1>\test1.cpp(51): error C2676: binary '[' : 'Account' does not define this operator or a conversion to a type acceptable to the predefined operator
    1>\test1.cpp(51): error C2228: left of '.displayCustomer' must have class/struct/union
    1>\test1.cpp(56): error C2676: binary '[' : 'Account' does not define this operator or a conversion to a type acceptable to the predefined operator
    1>\test1.cpp(56): error C2228: left of '.ApplyIntrest' must have class/struct/union
    1>\test1.cpp(62): error C2676: binary '[' : 'Account' does not define this operator or a conversion to a type acceptable to the predefined operator
    1>\test1.cpp(62): error C2228: left of '.displayCustomer' must have class/struct/union
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


    ==
     
  14. Feb 15, 2010 at 9:22 PM
    #34
    NetMonkey

    NetMonkey Well-Known Member

    Joined:
    Aug 14, 2008
    Member:
    #8536
    Messages:
    1,734
    Gender:
    Male
    Geogetown, TX
    Vehicle:
    2010, 4x4, DC, off-road, shortbed, automatic
    Toytec Ultimate Lift @ 3", Mickey Thompson MTZ's 285/75/16, Moto Metal 955b, rear 2" ALL, Marlin Crawler sliders
    try making those variables static as well

    1>\account.h(53): error C2597: illegal reference to non-static member 'Account::type'
    1>\account.h(57): error C2597: illegal reference to non-static member 'Account::number'

    1>\account.h(61): error C2597: illegal reference to non-static member 'Account::balance'
     
  15. Feb 15, 2010 at 9:27 PM
    #35
    tarheelfan_08

    tarheelfan_08 [OP] Carolina Alliance

    Joined:
    Jan 4, 2008
    Member:
    #4098
    Messages:
    2,944
    Gender:
    Male
    First Name:
    Justin
    North Carolina
    Vehicle:
    2010 White 4x4 Double Cab Tacoma Short Bed
    Chrome Grill, Chrome accessories(door handles and mirror covers), LEER Super White Cover, Mirrors with Turn Signals, Window Vent Visors, Step Rails, WeatherTech Digital Floor Mats, Mini Maglight Holder, Chrome Bull Bar
    Code:
    #ifndef ACCOUNT_H
    #define ACCOUNT_H
    
    #include "Customer.h"
    
    //Account Class
    class Account {
    private:
            Customer myCustomer[2];
            static string type;
            static int number;
            static double balance;
            static double rate;
    
            double intrest;
            double NewBalance;
    
    public:
            Account(); // Constructor
            Account(string, int, double, double) ;
                    static void setType(string);
                    static void setNumber(int);
                    static void setBalance(double);
                    static void setRate(double); 
    
                    string getType();
                    int getNumber();
                    double getBalance();
                    double getRate();
                    Customer& getCustomer ( int );
                    static void valid_rate(double);
                    void ApplyInterest();
                    void operator += (Account&);
                    void operator -= (Account&);
                    void operator ++ (int);
                    };       
    //-----------------------------------------------------------------------------
    //class definition
            Account::Account() {
                    type = " ";
                    number = 0;
                    balance = 0;
                    rate = 0;
            }
    
            Account::Account(string type, int number, double balance, double rate) {
                    Account::type = type;
                    Account::number = number;
                    Account::balance = balance;
                    valid_rate(rate);
                    }
    void Account::setType(string type) {
        Account::type = type;
    }
    
    void Account::setNumber(int number) {
        Account::number = number;
    }
    
    void Account::setBalance(double balance) {
        Account::balance = balance;
    }
    
    void Account::setRate(double rate) {
            valid_rate(rate);
    }
    
    string Account::getType() {
        return type;
    }
    int Account::getNumber() {
        return number;
    }
    double Account::getBalance() {
        return balance;
    }
    double Account::getRate() {
        return rate;
    }
    
    void Account::valid_rate(double rate) {
            if (rate >=.01 && rate <= .1)
                    Account::rate=rate;
            else {
                    Account::rate=0;
                    cout << "WARNING! You have entered an invalid rate!\n";
            }
    }
    
    void Account::ApplyInterest() {
                    intrest = rate * balance;
                    NewBalance = intrest + balance;
                    cout << "The amount of intrest for the Customer is: $" << intrest << " and the account balance is: $" << NewBalance << ".\n";
    }       
    
    
    Customer& Account::getCustomer(int n) {
            return myCustomer[n];
    }
    
    void Account::operator += (Account& a) {
            a.setBalance(a.getBalance()+ a.getBalance());
        }
        void Account::operator -= (Account& a) {
            a.setBalance(a.getBalance() - a.getBalance());
        }
    
        void operator ++ (Customer& customer) {
               int temp_savings = customer::getSavings();
               int temp_checking = customer::getChecking();
               Account::setBalance(temp_savings  +  temp_checking);
            }
    
    #endif
    
    1>------ Build started: Project: Test1, Configuration: Debug Win32 ------
    1> Test1.cpp
    1>\account.h(109): error C2653: 'customer' : is not a class or namespace name
    1>\account.h(109): error C3861: 'getSavings': identifier not found
    1>\account.h(110): error C2653: 'customer' : is not a class or namespace name
    1>\account.h(110): error C3861: 'getChecking': identifier not found
    1>\test1.cpp(5): error C2143: syntax error : missing ';' before 'using'
    1>\test1.cpp(28): error C2039: 'getDate' : is not a member of 'Account'
    1> \account.h(7) : see declaration of 'Account'
    1>\test1.cpp(28): error C2228: left of '.setDate' must have class/struct/union
    1>\test1.cpp(40): error C2660: 'Account::getRate' : function does not take 1 arguments
    1>\test1.cpp(40): error C2228: left of '.setRate' must have class/struct/union
    1>\test1.cpp(51): error C2676: binary '[' : 'Account' does not define this operator or a conversion to a type acceptable to the predefined operator
    1>\test1.cpp(51): error C2228: left of '.displayCustomer' must have class/struct/union
    1>\test1.cpp(56): error C2676: binary '[' : 'Account' does not define this operator or a conversion to a type acceptable to the predefined operator
    1>\test1.cpp(56): error C2228: left of '.ApplyIntrest' must have class/struct/union
    1>\test1.cpp(62): error C2676: binary '[' : 'Account' does not define this operator or a conversion to a type acceptable to the predefined operator
    1>\test1.cpp(62): error C2228: left of '.displayCustomer' must have class/struct/union
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
     
  16. Feb 15, 2010 at 9:30 PM
    #36
    NetMonkey

    NetMonkey Well-Known Member

    Joined:
    Aug 14, 2008
    Member:
    #8536
    Messages:
    1,734
    Gender:
    Male
    Geogetown, TX
    Vehicle:
    2010, 4x4, DC, off-road, shortbed, automatic
    Toytec Ultimate Lift @ 3", Mickey Thompson MTZ's 285/75/16, Moto Metal 955b, rear 2" ALL, Marlin Crawler sliders
    oops...

    i am getting tired too :)

    Code:
     
        void operator ++ (Customer& customer) {
               int temp_savings = [COLOR=red]customer.getSavings();[/COLOR]
               int temp_checking = [COLOR=red]customer.getChecking();
    [/COLOR]           Account::setBalance(temp_savings  +  temp_checking);
            }
    
     
  17. Feb 15, 2010 at 9:44 PM
    #37
    tarheelfan_08

    tarheelfan_08 [OP] Carolina Alliance

    Joined:
    Jan 4, 2008
    Member:
    #4098
    Messages:
    2,944
    Gender:
    Male
    First Name:
    Justin
    North Carolina
    Vehicle:
    2010 White 4x4 Double Cab Tacoma Short Bed
    Chrome Grill, Chrome accessories(door handles and mirror covers), LEER Super White Cover, Mirrors with Turn Signals, Window Vent Visors, Step Rails, WeatherTech Digital Floor Mats, Mini Maglight Holder, Chrome Bull Bar

    I tried this and it does not work! Do I need to change all of those statics back to normal or not??
     
  18. Feb 15, 2010 at 9:46 PM
    #38
    NetMonkey

    NetMonkey Well-Known Member

    Joined:
    Aug 14, 2008
    Member:
    #8536
    Messages:
    1,734
    Gender:
    Male
    Geogetown, TX
    Vehicle:
    2010, 4x4, DC, off-road, shortbed, automatic
    Toytec Ultimate Lift @ 3", Mickey Thompson MTZ's 285/75/16, Moto Metal 955b, rear 2" ALL, Marlin Crawler sliders
    what are the errors?
     
  19. Feb 15, 2010 at 9:48 PM
    #39
    dk6487

    dk6487 NorCal Member

    Joined:
    Jan 14, 2010
    Member:
    #29349
    Messages:
    247
    Gender:
    Male
    First Name:
    David
    Novato, CA
    Vehicle:
    08 Silver 4X4 TRD Sport w/ Tow Pack
    Pioneer Z110BT Nav/DVD H.U., Sub Box by Mr. Marv w/ amp and 10" Sub, Rear-Leaf TSB, L.E.D. Guage Mod, 3" OME Lift Kit w/ 885, Total Chaos UCA's
    Wow what is all this for?
     
  20. Feb 15, 2010 at 9:49 PM
    #40
    dk6487

    dk6487 NorCal Member

    Joined:
    Jan 14, 2010
    Member:
    #29349
    Messages:
    247
    Gender:
    Male
    First Name:
    David
    Novato, CA
    Vehicle:
    08 Silver 4X4 TRD Sport w/ Tow Pack
    Pioneer Z110BT Nav/DVD H.U., Sub Box by Mr. Marv w/ amp and 10" Sub, Rear-Leaf TSB, L.E.D. Guage Mod, 3" OME Lift Kit w/ 885, Total Chaos UCA's
    ^^ When you have time to respond cuz I know your running short on time.
     

Products Discussed in

To Top