a-nerd
2010-11-01 16:11:40 UTC
I am getting an error when I try to spread a program out in several files. Specifically, I get the error whenever I attempt to call a member method of my "printer" object that returns void and takes no arguments. The error displays when compiling.
Here's the error:
**** Build of configuration Debug for project ConsoleLanguage ****
make all
Building file: ../main.cpp
Invoking: GCC C++ Compiler
g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"main.d" -MT"main.d" -o"main.o" "../main.cpp"
../main.cpp: In function ‘int main(int, const char**)’:
../main.cpp:17: error: request for member ‘print’ in ‘prnt’, which is of non-class type ‘printer()’
make: *** [main.o] Error 1
here's main.cpp:
/*
* main.cpp
*
* Created on: Nov 1, 2010
* Author: *****
*/
#include
#include "printer.h"
using namespace std;
int main(int argc, const char** argv){
//First hello world!
cout << "Hello, World!" << endl;
//now do it with a different method:
printer prnt();
prnt.print();
return 0;
}
Here's printer.h:
* printer.h
*
* Created on: Nov 1, 2010
* Author: *****
*/
#ifndef PRINTER_H_
#define PRINTER_H_
class printer {
public:
printer();
virtual ~printer();
void print();
};
#endif /* PRINTER_H_ */
here's printer.cpp:
/*
* printer.cpp
*
* Created on: Nov 1, 2010
* Author: *****
*/
#include "printer.h"
printer::printer() {
// TODO Auto-generated constructor stub
}
printer::~printer() {
// TODO Auto-generated destructor stub
}
printer :: print(){
std::cout << "Hello, World!..." <
Where did I mistype?