class works, just wont display data
Jul 10, 2013 at 2:27am UTC
This is my class and it runs and prompts to enter the company and report, but it does not display the data. Also, if the user does not enter a company or report it is supposed to default to "ABC Industries" and "report" but that isn't working either.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
Tester.cpp
#include <iostream>
using namespace std;
#include "Heading.h"
int main()
{
string in_company;
string in_report;
cout << "Please enter company name: " ;
cin >> in_company;
cout << "Please enter report type: " ;
cin >> in_report;
Heading c1;
c1.displayOneLine();
c1.setCompany(in_company);
c1.setReport(in_report);
c1.displayBoxed();
c1.printData();
return 0;
}
Heading.h
#pragma once
#include <iostream>
#include <string>
#include "Heading.h"
using namespace std;
class Heading
{
private :
string company;
string report;
public :
// Heading(void);
//~Heading(void);
Heading::Heading(void );
Heading(string _company, string _report);
void setCompany(string _company);
void setReport(string _report);
void displayBoxed();
void displayOneLine();
void printData();
};
Heading.cpp
#include "Heading.h"
Heading::Heading(void )
{
}
Heading::Heading(string string_company, string string_report)
{
if (string_company == "" )
company = "ABC Industries" ;
else
company = string_company;
if (string_report == "" )
report = "Report" ;
else
report = string_report;
}
void Heading::setCompany(string string_company)
{
if (string_company == "" )
company = "ABC Industries" ;
else
company = string_company;
}
void Heading::setReport(string string_report)
{
if (string_report == "" )
report = "Report" ;
else
report = string_report;
}
void Heading::displayBoxed()
{
cout << company
<< report;
}
void Heading::displayOneLine()
{
cout << company << endl << report;
}
void Heading::printData()
{
cout << company << endl;
cout << report;
}
Jul 10, 2013 at 2:32am UTC
move the command on line 22 to 20
Topic archived. No new replies allowed.