Here’s what I’ve got. I’m trying to create an instance of Foo within in Bar, using a custom constructor. When I try to call the constructor from Bar’s constructor I get and unresolved external.
class Foo
{
public:
// The custom constructor I want to use.
Foo(const char*);
};
class Bar
{
public:
Bar();
//The instance of Foo I want to use being declared.
Foo bu(const char*);
};
int main(int argc, char* args[])
{
return 0;
}
Bar::Bar()
{
//Trying to call Foo bu's constructor.
bu("dasf");
}
Foo::Foo(const char* iLoc)
{
}
This is probably what you want:
As for this declaration:
Foo bu(const char*);This is a declaration of a member function namedbuwhich takes aconst char*and returns aFoo. The unresolved symbol error is because you never defined the functionbu, but you want an instance ofFoonot a function.Other method after seeing comments:
And there are also many other problems with your code, maybe getting a book on C++ like C++ Primer would be a good idea.