Klasse "error id ist nicht definiert"

Ich gehe davon aus das ist ein kleines syntax Problem, wenn ich entfernen Sie die Klasse und arbeiten nur in meiner cpp-Datei, die es ohne Probleme läuft...

Ich Klasse, die aufgerufen werden, indem Sie die main-Funktion. Das problem das ich laufen in ist, dass Sie nicht recoginized in der .cpp-Datei.

wenn es besser funktionieren würde haben-array oder Konstanten deklariert in der header-Datei lassen Sie mich wissen, wie gut...

#include '<iostream>'
#include "Menu.h"
using namespace std;


const double RestaurantCheck::MINTAX=.01, RestaurantCheck::MAXTAX=.12,RestaurantCheck::MINTIP=.05,RestaurantCheck::MAXTIP=.20,RestaurantCheck::DEFAULTTAX=.065,RestaurantCheck::DEFAULTTIP=.15;

//Error nonstatic data member may not be defiend outside of its class
RestaurantCheck::MexicanMenu[10].ItemName="Marisco El Sol";
RestaurantCheck::MexicanMenu[10].ItemDesc="Mouth watering seafood     appetizer made with shrimp, octopus, scallops, mushrooms, red and green peppers. Garnished with lettuce and avocado.";
RestaurantCheck::MexicanMenu[10].ItemCost=10.95;

RestaurantCheck::MexicanMenu[1].ItemName="Taquitos";
RestaurantCheck::MexicanMenu[1].ItemDesc="Rolled flour tortilla fried with your choice of chicken, shredded beef or shredded pork. Served over a bed of lettuce with Parmesan, tomatoes, guacamole & sour cream.";
RestaurantCheck::MexicanMenu[1].ItemCost=7.95;

            ...

            RestaurantCheck::MexicanMenu[0].ItemName=" ";//my null set.
            RestaurantCheck::MexicanMenu[0].ItemDesc=" ";
            RestaurantCheck::MexicanMenu[0].ItemCost=0;

void main()
{
    double ITax=0,ITip=0,Subtotal=0,UserTip=0,UserTax=0;
    bool exit=false;

    int count=0;//delete me after tests

    while (exit=false)
    {
        cout<<"Please input all tips as floating numbers 1% = .01 and 12% = .12\n";
        cout<<"What value do you want to set the tip? ";
            cin>>UserTip;
        cout<<endl<<"What value do you want to set the tax? ";
            cin>>UserTax;

        setFee(UserTip,UserTax);//error: Identifier is undefined
        placeOrder();...

Header

#ifndef Menu_H
#define Menu_H
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;


class RestaurantCheck
{
    struct Restaurant
    {
        string ItemName;
        string ItemDesc;
        double ItemCost;
    };

    static const double MINTAX,MAXTAX,MINTIP,MAXTIP, DEFAULTTAX,DEFAULTTIP;
    double Subtotal,CTax,TaxAmt,CTip,TipAmt;
    Restaurant Order[10],MexicanMenu[4];

    void presentMenu(Restaurant DispMenu[],int NumOfItems);

public:
    double calculateTax(double Subtotal,double CTax);
    double calculateTip(double Subtotal,double CTip);
    void setFee(double ,double );
    double issueCheck(Restaurant Order[],double ITax,double ITip,double Subtotal);
    void placeOrder(Restaurant Menu[],int Num_Menu,Restaurant IOrder[],int Num_Order);
    //void setMenu();


};
void RestaurantCheck::setFee(double UTip,double UTax)
{
    if (UTip>=MINTIP&&UTip<=MAXTIP)
        CTip=UTip;
    else
        CTip=DEFAULTTIP;

    if  (UTax>=MINTAX&&UTax<=MAXTAX)
        CTax=UTax;
    else
        CTax=DEFAULTTAX;
    //return(true);
};`
  • Der code ist nur ein großer Haufen von syntax-Fehler. Es gibt keinen einzigen Fehler gibt, die "fixiert". Sie brauchen, um ein Buch zu Lesen zu bekommen, eine grundlegende Idee darüber, wie man C++ - Klassen, nicht einmal zu erwähnen, Dinge wie while (exit=false)...
  • #include '<iostream>'? Was sind die Apostrophe dort tun?
  • alle die ich gesehen habe war void main
Schreibe einen Kommentar