我正在开发一个 c++ 程序,我已经创建了一个 TextUserInterface 类,并试图在 main 方法中调用它的一个实例。这是 TextUserInterface.h、TextUserInterface.cpp 和 GasStationFinder.cpp(包含主要方法)。
#include <iostream>
using namespace std;
using namespace view; // compiler is comlaining here saying '<type error>' is not
// a namespace and expected namespace name before ;
#include "TextUserInterface.h"
int main() {
view::TextUserInterface tui;
tui.run();
return 0;
}
文本用户界面.h
/*
* TextUserInterface.h
*
* Created on: Jan 27, 2013
* Author: Chris
*/
#ifndef TEXTUSERINTERFACE_H_
#define TEXTUSERINTERFACE_H_
namespace view {
class TextUserInterface {
public:
TextUserInterface();
void run();
virtual ~TextUserInterface();
};
} /* namespace view */
#endif /* TEXTUSERINTERFACE_H_ */
文本用户界面.cpp
/*
* TextUserInterface.cpp
*
* Created on: Jan 27, 2013
* Author: Chris
*/
#include <iostream>
using namespace std;
#include "TextUserInterface.h"
namespace view {
TextUserInterface::TextUserInterface() {
// TODO Auto-generated constructor stub
}
void TextUserInterface::run(){
cout << "Welcome to the Gas Station Finder" << endl;
cout << "" << endl;
cout << "What would you like to query: (m)inimum price, ma(x)imum price,
(p)repay pumps, (t)hreshold price, (l)ist stations, (q)uit?" << endl;
}
TextUserInterface::~TextUserInterface() {
// TODO Auto-generated destructor stub
}
} /* namespace view */