我的问题是,我似乎无法通过引用另一个类来发送对象。我在网上查到这一点时运气不佳。如果可以,请检查我的来源,如果您有任何想法,请告诉我。TYIA-罗兰
我也收到这些错误
error: field 'PgmClass' has incomplete type
error: 'PgmClass' does not name a type
error: expected ')' before 'thesource'
error: 'm_hereitis' was not declared in this scope
#include <iostream>
#include "pgmclass.h"
#include "inclobj.h"
int main()
{
char catchcin[256];
PgmClass wilko;
wilko.addToSet( 7 );
wilko.addToSet( 8 );
wilko.addToSet( 9 );
InclObj alpha( wilko );
wilko.addToSet( 10 );
wilko.addToSet( 11 );
// This doesn't work
alpha.eraseOne( 10 );
// How can I get this to work using referances?
std::cout << "Program Running." << std::endl;
std::cin >> catchcin;
return 0;
}
----------
#include <set>
class PgmClass {
public:
int addToSet( int );
bool eraseSet( int );
std::set<int> m_userset;
};
int PgmClass::addToSet( int theint ) {
m_userset.insert( theint );
}
bool PgmClass::eraseSet( int eraseint ) {
m_userset.erase( eraseint );
}
----------
class InclObj {
public:
InclObj( PgmClass );
void eraseOne( int );
PgmClass m_hereitis;
};
InclObj::InclObj( PgmClass thesource ) {
m_hereitis = thesource;
}
void InclObj::eraseOne( int findint ) {
m_hereitis.eraseSet( findint );
}