When there is a dispute between claims of a programmer and the results of the build process, I would be willing to bet the programmer is mistaken.
So you tell us. However, you're the one withholding information you deem irrelevant, and forcing us to guess what relevant information you've withheld.
You don't need to provide your complete project, but a SMALL and complete example of code that illustrates your concern will be useful. In the process of creating such an example (cutting out the irrelevant bits and testing) you might even find the actual problem yourself.
Providing a header file is not enough. You are reporting problems in the build process, and a header file can't usually be compiled in isolation. The problem you have is almost certainly due to some interaction between your header file and the source file (or files, although I note your repeated claim there is only one) that #include it.
Your header file is at odds with quite a few good coding practices.
1) NEVER employ "using namespace std;" in a header file. That is an effective way to break code that #include's that header file - often in a manner that is unsolvable. Yes, that means you need to sprinkle "std::" prefixes everywhere.
2) You have declared member functions of your class as inline. However, it is the definitions (i.e. implementations) of the functions that need to be inline.
3) It is rather pointless (and also expensive) to throw an exception and then immediately catch it in order to rethrow it.
4) Your class effectively uses member functions to return references to private members. That is essentially bypassing the benefits of having private members.
As far as I am aware, you only need to declare a function inline for it to be inline. You don't need the inline keyword in the definition or implementation.
Thus, Programmer_P's way of defining the functions inline in the class is valid, AFAIK.
(It being a good idea is another matter.)
1) Oops...forgot I did that. I'll fix that.
2) I don't think that's true. It can be written before either or both. But I went ahead and put it before both shortly after attaching the file here.
3) While that may be, I did that only to get rid of a compiler error saying it expected a catch before the next coding statement. It seems that that is a requirement.
4) No, my functions all return const references.
As mentioned above, I changed it already to have inline before both declarations and definitions.
And just to clear up another point, I am not ignoring the request for a small compilable example. Its just I'm a little bit busy right now, and it'll have to be sometime later.
Last edited by Programmer_P; 03-04-2011 at 05:53 PM.
I'm an alien from another world. Planet Earth is only my vacation home, and I'm not liking it.
That should not be a requirement. Possibly you did not understand the compiler error or you did something weird?
You are never required to catch an exception.
Possibly you also tried to add a try block. Each try block requires at least one catch block. However, you do not need a try block to throw exceptions.
If you are not going to catch an exception, then don't add a try block.
Ok, it turns out that other error was completely un-related to the original error that I was getting. It was about something else entirely.
The last error that I mentioned was due to not defining a class function that I declared. I forgot I had declared that one, and it took me some time to figure out how to display the complete linking error in Qt Creator. Once I did, I immediately learned what was causing the error, and fixed it on my own.
Cheers...and thanks people.
I'm an alien from another world. Planet Earth is only my vacation home, and I'm not liking it.