Saturday, 20 March 2010

C++ and XCode Help


hello,

new programming , taking intro class. having trouble xcode , getting code compile multiple files. using headers, keep receiving following errors.

on consoleui.cpp, 2 errors:
1. no previous prototype function "consoleui"
2. no matching function call "paintjobestimator"

on paintjobestimator.cpp, 1 error:
1. no previous prototype function "paintjobestimator"


if help, grateful. thank you. below code. can't compile test if logic works.


main.cpp:
code:
 #include <iostream>  // include header file #include "consoleui.h"  using namespace std;       void consoleui();  int main() {          consoleui();          return 0; } 
consoleui.cpp:
code:
 #include <iostream> #include <iomanip>  // include header file #include "paintjobestimator.h"   using namespace std;    // begin console ui void consoleui () {              int rooms = 0;              // number of rooms     int cnt = 0;                // counter rooms     double paint = 0.00;        // number of gallons of paint     double ceilpaint = 0.00;    // paint rounded     double labor = 0.00;        // labor hours needed     double sqft = 0.00;         // square footage of wall     double laborcost = 0.00;    // cost of labor     double paintcost = 0.00;    // cost of paint     double priceofpaint = 0.00; // price of paint * paintcost     double totalcost = 0.00;    // total cost     bool isvalid = false;       // loop validation           // input rooms     cout<<"how many rooms paint?\n";     cin>>rooms;     cout<<"you entered: "<<rooms <<" rooms.\n";          // input paint cost     cout<<"what price of paint per gallon?\n";     cin>>paintcost;               // input validation loop     while (! isvalid)     {                  // loop calculation of each room         (cnt=0; cnt<=rooms; cnt--)         {                          if (rooms > 0 && rooms <= 25)             {                 cout<<"what total square footage walls of entire room?\n";                 cin>>sqft;                                  sqft += sqft;                                                       if (sqft > 0.00)                 {                                         if (paintcost >= 10.00)                     {                         isvalid = true;                     }                                     }                             }                           else             {                 cout<<"invalid entry.\n";             }                      }                          }          // call function compute costs     paintjobestimator (paint, labor, sqft, paintcost, laborcost, priceofpaint);                // output costs         cout << fixed << setprecision(2);     cout <<"number of gallons of paint: " << ceilpaint <<endl;     cout <<"hours of labor: " << labor <<endl;     cout <<"cost of paint: $"<< setw(7) << paintcost <<endl;     cout <<"labor charge: $"<< setw(7) << laborcost <<endl;     cout <<"total cost: $"<< setw(7) << totalcost <<endl;           }   
paintjobestimator.cpp:
code:
 #include <stdio.h> #include <math.h> #include <cmath>  double paintjobestimator (double& ceilpaint, double& paint, double& labor, double& sqft, double& paintcost, double& laborcost, double& priceofpaint, double& totalcost) {     // ceiling function gallons of paint         ceilpaint = sqft/115;     paint = ceil (ceilpaint);          // cost of labor, paint & total costs     labor = ((sqft/115) * 8);     laborcost = labor * 18.00;     priceofpaint = paint * paintcost;     totalcost = laborcost + priceofpaint;          return 0; } 
consoleui.h:
code:
 #ifndef paint_job_estimator_consoleui_h #define paint_job_estimator_consoleui_h  void consoleui ();  #endif 
paintjobestimator.h:
code:
 #ifndef paint_job_estimator_paintjobestimator_h #define paint_job_estimator_paintjobestimator_h  double paintjobestimator (double& ceilpaint, double& paint, double& labor, double& sqft, double& paintcost, double& laborcost, double& priceofpaint, double& totalcost);  #endif 
 

a source file paintjobestimator.cpp include paintjobestimator.h unless have very reason not to. same consoleui.cpp , consoleui.h.

next, compare call paintjobestimator , actual function very, carefully.
 


Forums Macs Mac Programming


  • iPhone
  • Mac OS & System Software
  • iPad
  • Apple Watch
  • Notebooks
  • iTunes
  • Apple ID
  • iCloud
  • Desktop Computers
  • Apple Music
  • Professional Applications
  • iPod
  • iWork
  • Apple TV
  • iLife
  • Wireless

No comments:

Post a Comment