October 2011
Beginner to intermediate
1200 pages
35h 33m
English
string Class Member?Can you use a string class object instead of a character array for the name member? That is, can you declare a structure like this:
#include <string>struct inflatable // structure definition{ std::string name; float volume; double price;};
The answer is yes unless you are using an obsolete compiler that does not support initialization of structures with string class members.
Make sure that the structure definition has access to the std namespace. You can do this by moving the using directive so that it is above the structure definition. The better choice, as shown previously, is to declare name as having type std::string.
Read now
Unlock full access