Hiya. New to forums, so excellent to have a community of budding game coders, thanks Mike for an excellent book!
Okay- onto the question:
I downloaded some source code included in the book, and since i'm in the process of learning C++'s more advanced of features and things, I made a "sandbox" project, where I just write code, compile, and see how different modules work. One of the things I got around to trying was the optional<T> template!
So, for one of my little mini-code things, I got to write a method that returns a optional<int>, because it could give a valid value, or an invalid value. I didn't want to use exceptions for that due to overheads.
Upon using that, optional.h is parsed, but somehow it throws a trillion errors. it says, "error: m_bValid undeclared (first use of function)". However it is quite clear to me that m_bValid is a member of the optional_base, and optional is derived from optional_base.
It also moans about m_Data in the same way. They are the only errors.
I can't understand what the compiler's complaining about. Does anybody else have problems with optional.h?
Yes, I #included "optional.h" (with the correct path) into the source file that was using optional<T>.
I can assure you all my other code compiles fine, and all required libraries are linked correctly etc.
And also on a general note, did I read somewhere you HAVE to put template classes in the same file as where they're gonna be used?... In that case what's the good of the header file with templates in them?
Your help is appreciated! Thanks!
OS: Windows XP SP2
Compiler: MingW g++
IDE: Eclipse with CDT (lol probably the only one using Eclipse)
Okay- onto the question:
I downloaded some source code included in the book, and since i'm in the process of learning C++'s more advanced of features and things, I made a "sandbox" project, where I just write code, compile, and see how different modules work. One of the things I got around to trying was the optional<T> template!
So, for one of my little mini-code things, I got to write a method that returns a optional<int>, because it could give a valid value, or an invalid value. I didn't want to use exceptions for that due to overheads.
Upon using that, optional.h is parsed, but somehow it throws a trillion errors. it says, "error: m_bValid undeclared (first use of function)". However it is quite clear to me that m_bValid is a member of the optional_base, and optional is derived from optional_base.
It also moans about m_Data in the same way. They are the only errors.
I can't understand what the compiler's complaining about. Does anybody else have problems with optional.h?
Yes, I #included "optional.h" (with the correct path) into the source file that was using optional<T>.
I can assure you all my other code compiles fine, and all required libraries are linked correctly etc.
And also on a general note, did I read somewhere you HAVE to put template classes in the same file as where they're gonna be used?... In that case what's the good of the header file with templates in them?
Your help is appreciated! Thanks!
OS: Windows XP SP2
Compiler: MingW g++
IDE: Eclipse with CDT (lol probably the only one using Eclipse)
A Toyota's a toyata.
A dog, a panic in a pagoda!
God! A red nugget! A fat egg under a dog!
Go hang a salami, I'm a lasagna hog!
A dog, a panic in a pagoda!
God! A red nugget! A fat egg under a dog!
Go hang a salami, I'm a lasagna hog!