Hi guys,
I have been away from programming for a while and i started back today now that i have some time again. However i have run into a bit of a brick wall. im trying to impliment a queue with a simplified interface for holding messages.
What I have got:
//class msgQ
class msgQ
{
public:
msgQ() : m_numMSGs(0) {};
~msgQ() { m_MSGs.clear(); };
void GetMSG( msg& newMSG );
void AddMSG( msg& newMSG );
int GetNumMSGs( void ) { return m_numMSGs; };
protected:
int m_numMSGs;
std::list<msg> m_MSGs;
};
//add msg
void msgQ::AddMSG( msg& newMSG )
{
m_MSGs.push_back( newMSG );
++m_numMSGs;
}
// in main()
msg myNewMessage;
msgQ myQ;
cout << "adding element!" << endl;
myQ.AddMSG(&myNewMessage); // <---- this line is where it says the error is
cout << "Q size: " << myQ.GetNumMSGs() <<endl;
To this visual studio says : cannot convert parameter 1 from 'msg *' to 'msg &'
From what i understood when passing things to a function, it works like as i lay out below
//if i make classType classInstance;
someFN( classInstance ); //function gets a copy of classInstance
someFN( &classInstance ); //function gets reference to classInstance
//and then if i had done classType *classInstance;
someFN( classInstance ); //function gets the pointer classInstance which points to an actual instance
So like i said then, from what i understand as i have asked for a reference in my function and im passing a reference it should not be expecting a pointer?
I aplogise if this seems like a stupid question but i really dont understand the problem it is finding.
Thanks in advance