Simple C++ error: Cannot convert at initialization
Hey guys. I have a very simple code that's spewing out an error:
Code:
#include <iostream>
#include <string>
#include "NodeWord.h"
using namespace std;
NodeWord::~NodeWord(){
}
NodeWord::NodeWord(string& word){
data = word;
}
int main()
{
NodeWord * n("New Word");
cout << n->data << endl;
return 0;
}
Where my NodeWord.h is simple a header file of the above constructor/destructor, plus:
All are public.
Now when I try to compile it, it gives me the following error:
Code:
error: cannot convert 'const char*' to 'NodeWord*' in initialization
Naturally, without making n a pointer it works, but as a pointer it doesn't work. This might be a very simple error on my part (complete noob at C++) but any help will be very, VERY APPRECIATED!
Cheers!