Hi,
I am a complete newbie to C++, I come from Perl and used to know a little C++, but I very newbie. I am just trying to include a header file and its class (I get no errors from the include) and then create an object. Thats all that I'm doing at this point, except for some stuff that also worked without error, taking command line variables and printing them back out (that stuff I won't copy here, I promise you it works). The bug is either in my include and call to the constructor in the main file (hello_world.c) or its in the header file or the class file or something to with with how I include them. The bug from g++ is "expected primary-expression before publicagent" and "expected ";" before publicagent"
My code goes like this:
Code:
#include <iostream>
#include <cstdlib>
#include "PublicFirm.h"
// global variables and user input
int input;
... // 5 more
int main (int argc, char* argv[])
{
if( argc != 6 )
{
cout << "Usage ...\n";
exit(0);
}
cout<< "hello\n";
input = atoi(argv[1]);
... // 5 more
cout<< "Okay, strarting...";
PublicFirm publicagent;
cout << "instantiated\n";
return 0;
}
The header and class files look like this:
header:
#ifndef __PublicFirm__
#define __PublicFirm__
namespace PublicFirm
{
class PublicFirm
{
// trial
private:
int privatevalue;
// constructor
// destructor
// trial method
public:
PublicFirm();
virtual ~PublicFirm();
virtual int getValue();
};
}
#endif
the class file:
#include "PublicFirm.h"
#include <stdio.h>
namespace PublicFirm
{
PublicFirm::PublicFirm()
{
//cout << "Constructing...";
//privatevalue += 1;
}
PublicFirm::~PublicFirm()
{
//cout << "Destructing...";
}
int PublicFirm::getValue(int i)
{
//cout << privatevalue;
//return privatevalue;
}
}
-- I commented most of it out for debugging...
So, am I missing something such that the files are not included properly? Or is there some other obvious bug in there?
any thoughts appreciated!