Tip Bank

DevX - Software Development Resource

Returning a Value

Question: When executing a system call, how can I return a value back? My program will already return a value back. Example: String blah = system(“some command”); Is this correct?

DevX - Software Development Resource

Address of a Constructor

Question: How can I obtain the address of a constructor for a C++ class object? Answer: A constructor is not an ordinary member function. You cannot take its address.

DevX - Software Development Resource

STL and User-Defined Classes

Question: I’m new to the Standard Template Library. How do I incorporate a user-defined class into a hash_map? What functions do I need to overload? I get compiler errors when

DevX - Software Development Resource

Default String Class

Question: Is there a built-in or default string class in C++ or do I have to create my own? If so, what file can I look in to see the

DevX - Software Development Resource

Initializing a Const Member

Question: I’m trying to initialize a const declared in a class. How do I do this? This example fails: class MyClass {private: const int A;}MyClass::MyClass () { A = 1;}

DevX - Software Development Resource

Templates and Nested Classes

Question: What is the C++ syntax for defining a function that belongs to a nested class that is contained within a template class? For example: template class A{ protected: //

DevX - Software Development Resource

Eight-Byte Data Types

Question: I am looking for a data type in C++ that takes eight bytes. I have tried long, long int, and so forth, but they are all four bytes on

DevX - Software Development Resource

Array of Objects

Question: I have two questions. How do I pass an array of objects as an argument? How do I fix an error like “do or while loops are not expanded