Can I use a local struct to store data in the "set" conatiner? If so, what is the correct method to do so?
Compiler: Sun Studio 10 on Unix (Sun Solaris)
Code:#include<iostream> #include<set> using namespace std; int main() { struct product { int id; string desc; double amt; } prdt; prdt.id = 1234; prdt.desc = "Credit Card"; prdt.amt = 1000.00 ; cout << " This is a program to test set conatainer. " << endl << " Product ID is: " << prdt.id << ", Product Desc is : " << prdt.desc << ", Credit Card Limit is : " << prdt.amt << endl ; // Test program for 'set' container with a struct typedef std::set< product, std::less< int > > product_set; return 0; }
Error Message:"testSet.c", line 26: Error: The local type "product" cannot be used as a template argument.
"/opt/SunStudio10/SUNWspro/prod/include/CC/Cstd/./set", line 83: Error: The local type "product" cannot be used as a template argument.