This is a simplified version of an earlier post that went unanswered. I have tried to re-work things around without success. I still have no idea why the compiler recommends Vector<BoxMaker*> as a candidate. C++ is case sensitive yet I can create a vector with a line like:
Vector<int> test;
As a side note, I can "instantiate" the a MakeSmall object passing in no arguments even though its cstor is written to require one argument as you can see below. It does not even seem like that should compile!
Even if you don't know the answer, if you have any hunches please tell me anyway. This error has really been killing me. Thanks. BTW I am using DEV C++ IDE.
Error
In function `int main()':
no matching function for call to `MakeSmall::MakeSmall(std::vector<BoxMaker*, std::allocator<BoxMaker*> >)'
I'm not an expert but have been doing some stuff with vectors lately and was going to see if I could help.
With the problem line: MakeSmall Shrinker(MultiBox.GetTheBoxSet() );
Do you have more information on what .GetTheBoxSet() does? i.e.: Function GetTheBoxSet() in class Multiplier? Maybe if you could post what that function looks like I can understand a bit more, thanks.
Ignore my previous post I got the answer to my question in another one of your posts, I think I was on the wrong track anywhere, as firedraco suggests check the docs, it looks like its picking up "Vector" from somewhere else, I can check it out since I have a different environment.
Well done...that IS the file from Stroustrup's big blue text. (for those who don't know it is some error code used mainly with the try catch block for in-book examples) OK....so I guess that is why the compiler is saying I should try Vector with a capital V.
@Everyone....
But what about the cstor for MakeSmall? I still don't understand why the return value from GetTheBoxSet is not a good value to pass in to that cstor... Nor do I understand why a line like: MakeSmall Shrinker();
will compile when the MakeSmall cstor requires one argument? There is something big (or small) I don't see, clearly.
I am going to post the Multiplier.h cstor on this thread as well so everyone can see GetTheBoxSet().
Dammit. Was it necessary to make a separate thread?
Multiplier::GetTheBoxSet() is returning a vector<T>, which in the context of Multiplier.h means std::vector<T>. This context is kept when the file in included in main.cpp. In main.cpp, however, you try to assign this return value to a vector<T>, which in the context of main.cpp means Vector<T>, since there's a macro in effect turning vector into Vector.
Excellent. So now that it is known that the Stroustrup.h file includes a macro defining 'V'ector, can I make some alteration to main to make this work short of commenting out the offending line in Stroustrup.h?
@helios
I made the separate thread because no one replied to the first one. (until you did, but that was after the second thread was created.) I tried to make it shorter. I am new to forums and was not sure how much patience everyone generally has with reading through tons of included code. Looks like you were on the right track with your comment on the first thread. I was not even thinking about the Stroustrup include, but then again, I guess the bug is always where you are not looking. :)
As to "bad coding practices salad", I cannot defend myself on that charge as I am completely self-taught and still very much a novice. If you, or anyone else has any general recommendations or comments as to what makes the code so bad and how it might be improved I would love to hear about them. These forums are the only access I have to anyone who knows anything about C++ (or any other language for that matter).
Thanks for all the help.
As to "bad coding practices salad", I cannot defend myself
I meant it more as a critique on this: #define one_identifier another_identifier
That's moronic. Specially when one_identifier happens to be defined in the std namespace.
Ugh.
OK....I commented out that section in Stroustrup.h and now it will compile. Is the fact that it would compile when I instantiated MakeSmall without passing an in argument related? This is really a subpoint, less important, but equally baffling.
@helios
Yeah, that code is a crutch to be used for the Stroustrup textbook that I managed to run afoul. I have not gotten around to writing my own try/catch routines and really have no idea what is in there. From where I sit it is still a black box.