Hi
I am attempting to pass a reference to an object from one function to another, is this even possible, if so what is the syntax this is an example of what I want:
class SomeClass {
public:
int a = 100;
};
void second_function(SomeClass & ref_to_classobj)
{
std::cout << ref_to_classobj.a << endl;
}
int main()
{
SomeClass classobj;
second_function(classobj);
return 0;
}
Obviously the functions and classes I am using are a lot more complicated the class itself in the program I am writing takes about 5 seconds to construct due to it dealing and containing a huge amount of data. I don't want to have to reinitialise this class everytime I use it I want to just be able to point a reference to it. Does anyone know how to do this?
I have tried the method above, also:
void foo(SomeClass &reference)
void foo(SomeClass *reference)
and about 10 other variations on this, the usual error message I get is:
no matching function for call to `keyword_cache::find_keyword(const char[6])'
Any help will be greatly appreciated.
Thanks
Ben