cout not identified in methods
I have a class Establishment with methods introduction() and testPrint()
in both of these methods i try to use cout and i get an "identifier cout is undefined"
cout works in main()
can anyone see where im going wrong?
I've included my code below. This version will not compile - but if you comment out all the print statements in RESTAURANT.CPP it works...
main.cpp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
#include <iostream>
#include "RESTAURANT.H"
using namespace std;
int main ()
{
Establishment myRestaurant;
introduction();
myRestaurant.testPrint();
cout << "This print statement works " << endl;
getchar();
return 0;
}
|
RESTAURANT.CPP
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
|
#include "RESTAURANT.H"
#include <iostream>
void introduction()
/*********************************************************************************
Pre: None
Post: Banner to introduce the game
*********************************************************************************/
{
cout << "================================================================\n\n" <<endl;
cout << "\t\t\t\"Restaurant Game\"\n\n" <<endl;
cout << "================================================================\n\n" <<endl;
cout << " Congratulations on opening your first restaurant - it may be" <<endl;
cout << "just a \"hole in the wall\" but remember, many great restaurants" <<endl;
cout << "have humble beginnings.\n" <<endl;
}
void Establishment::testPrint()
/*********************************************************************************
Pre: stub
Post: stub
*********************************************************************************/
{
cout << "This is a stub" << endl;
}
|
RESTAURANT.H
1 2 3 4 5 6 7 8
|
class Establishment{
public:
void testPrint();
};
void introduction();
|
Last edited on
figured it out!
it requires std::cout and std::endl
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
|
#include "RESTAURANT.H"
#include <iostream>
void introduction()
/*********************************************************************************
Pre: None
Post: Banner to introduce the game
*********************************************************************************/
{
std::cout << "================================================================\n\n" << std::endl;
std::cout << "\t\t\t\"Restaurant Game\"\n\n" << std::endl;
std::cout << "================================================================\n\n" << std::endl;
std::cout << " Congratulations on opening your first restaurant - it may be" << std::endl;
std::cout << "just a \"hole in the wall\" but remember, many great restaurants" << std::endl;
std::cout << "have humble beginnings.\n" << std::endl;
}
void Establishment::testPrint()
/*********************************************************************************
Pre: stub
Post: stub
*********************************************************************************/
{
std::cout << "This is a stub" << std::endl;
}
|
Topic archived. No new replies allowed.