Have a simple container class:
public Container 
{
   public:
   Container() {}
   Container(const Container& cont)          //option 1
   { 
       SetMyString(cont.GetMyString());
   }
   //OR
   Container(const Container& cont)          //option 2
   {
      m_str1 = cont.m_str1;
   }
   public string GetMyString() { return m_str...
            
           
          
            
            Presently, I am using the following function template to suppress unused variable warnings:
template<typename T>
void
unused(T const &) {
  /* Do nothing. */
}
However, when porting to cygwin from Linux, I am now getting compiler errors on g++ 3.4.4 (On linux I am 3.4.6, so maybe this is a bug fix?):
Write.cpp: In member function `vo...
            
           
          
            
            Hi!
According to following resources, in C++(Specially Visual C++) scoped static variable initialization isn't thread safe. But, global static variables are safe.
http://stackoverflow.com/questions/1052168/thread-safe-static-variables-without-mutexing
http://blogs.msdn.com/oldnewthing/archive/2004/03/08/85901.aspx
So, is following co...
            
           
          
            
            When trying to change it,throw an exception.
...
            
           
          
            
            Hi,
I have a class with private member variables declared in a header file. In my constructor, I pass in some filenames and create other objects using those names. This works fine. When I try to add another member variable, however, and initialize it in the constructor, I get an access reading violation. I sent the code to someone else ...
            
           
          
            
            Hi,
I am trying grab all the member variables in AS3, and then foreach one i would like to process it in various ways. I would need the name and then if it is a collection of some type I would like to loop through that collection as well. I am attempting to essentially serialize in a somewhat custom fashion.
Thanks!
...
            
           
          
            
            I have a function that gets a value from the database and returns it. I call the function to store it into a member variable but I get the following error:
Parse error: parse error, expecting `','' or `';'' in I:\wamp\www\deposit\classes\Site.php on line 14
This is the line that causes the error
public static $depositmoney = self::ge...
            
           
          
            
            
  Possible Duplicate:
  Accessing private members
  Is it possible to access private members of a class?
Is there a good (yes I know this is ugly) way to hack to the private data members of a class?
One brute force approach is to copy the header file and in my copy change private to public.  But would there be a better way, say doi...
            
           
          
            
            Hi,
  I'm writing a member function that uses a member variable pointer as an iterator. However I want to reference the pointer within the function purely for readability's sake. Like so:
/* getNext will return a pos object each time it is called for each node
 * in the tree. If all nodes have been returned it will return a Pos
 * objec...
            
           
          
            
            If I have a class that has many int, float, and enum member variables, is it considered efficient and/or good practice to return them as references rather than copies, and return constant references where no changes should be made? Or is there a reason I should return them as copies?
...