Elliott <ew*****@gmail.comwrote:
Hello Everyone,
I have a function in a header (KeyDialog.h) as such:
void setKey(Key&);
The function implementation is as such (KeyDialog.cpp):
void KeyDialog::setKey(Key& k1)
{
Key::Key K1 = k1;
//unimportant
}
And I'm calling this function from another cpp file (mainwindow.cpp)
like so:
KeyDialog::setKey(enter);
When I compile I get the error: Cannot call member function 'void
KeyDialog::setKey(Key&)' without object...
This is probably stupidly simple, what am i missing?
You are missing an object. Try one of these in the other cpp file:
KeyDialog kd;
kd.setKey( enter );
There is probably some other fundamental error in your code though. It
may be that your "setKey" function doesn't need an object and therefore
should not be in the KeyDialog class.