All pastes #896863 Raw Edit

fall0ut

public text v1 · immutable
·published 2008-02-09 00:40 UTC
rendered paste body
int id;
int today;
float cash;

// base class for our program
class transaction {
  public:
    // our public accessor methods
    int getId();
    int getDate();
    float getAmt();

    // our public mutator methods
    void setId();
    void setDate();
    void setAmt();

  private:
    int sales_id;
    int sales_date;
    float sales_amt;
};

// accessor methods for transaction
int transaction::getId() {
  return sales_id;
}

int transaction::getDate() {
  return sales_date;
}

float transaction::getAmt() {
  return sales_amt;
}

// mutator methods for transaction
transaction::setId(id) {
  sales_id = id;
}

transaction::setDate(today) {
  sales_date = today;
}

transaction::setAmt(cash) {
  sales_amt = cash;
}

// derived class, salesperson
class salesperson: public transaction {
  public:
    char my_name;
};

// main()
int main() {
  // insert actions here

  return 0;
}
~
~
~
~
~
~
~
~
~
~
foo.cpp: 64 lines, 903 characters.
[gobinau@barbados] (~) 18:45:19 $g++ -Wall -Wno-deprecated foo.cpp
foo.cpp:41: error: expected constructor, destructor, or type conversion before '(' token
foo.cpp:45: error: expected constructor, destructor, or type conversion before '(' token
foo.cpp:49: error: expected constructor, destructor, or type conversion before '(' token
[gobinau@barbados] (~) 18:45:21 $