title: Error: C2228: left of '' must have class/struct/union
body: <p>I'm a long time Java user learning C++ with Qt and I'm having a lot of trouble understanding how methods work. Right now, I'm trying to figure out databases, and tried to simplify my code with a header. Normally in Java I would just have a class called DatabaseControl with a void method that would execute whatever I wanted. For example, adding an employee to a database, as I'm doing now. I'd instantiate the class, by doing something like</p>
  
  <pre><code>DatabaseControl myDBControl = new DatabaseControl();
  </code></pre>
  
  <p>and then execute the method with</p>
  
  <pre><code>myDBControl.addEmploye();
  </code></pre>
  
  <p>which would bring up the series of input boxes for the user to input the information on the employee - name, department, etc.</p>
  
  <p>So, now over to C++. I have my header</p>
  
  <pre><code>class DatabaseControl
  {
  public:
      DatabaseControl();
      ~DatabaseControl();
  
      //Methods
      void addEmployee();
  };
  </code></pre>
  
  <p>I don't have any parameters in my constructors because all I want to do is call the "addEmployee" method in my main as I've shown above. In the same header file I have this below my class declaration</p>
  
  <pre><code>void DatabaseControl::addEmployee(){
  QSqlQuery qry;
  bool ok;
  QString firstName = QInputDialog::getText(NULL, "QInputDialog::getText()",
                                       "Employee first name:", QLineEdit::Normal,
                                       NULL, &amp;ok);
  if (ok &amp;&amp; !firstName.isEmpty()){}
  else{
      QMessageBox msgBox;
      msgBox.setWindowTitle("Error");
      msgBox.setText("Failed to add employee.\nReason: No employee name given.");
      msgBox.exec();
  }
  QString lastName = QInputDialog::getText(NULL, "QInputDialog::getText()",
                                       "Employee last name:", QLineEdit::Normal,
                                       NULL, &amp;ok);
       if (ok &amp;&amp; !lastName.isEmpty()){
           qry.prepare("INSERT INTO employees (firstname, lastname)" "VALUES (:f1, :f2)");
           qry.bindValue(":f1", firstName);
           qry.bindValue(":f2", lastName);
           qry.exec();
       }
       else{
           QMessageBox msgBox;
           msgBox.setWindowTitle("Error");
           msgBox.setText("Failed to add employee.\nReason: No employee name given.");
           msgBox.exec();
       }
  </code></pre>
  
  <p>}</p>
  
  <p>and then in my main I have this:</p>
  
  <pre><code>void MainWindow::on_addEmployee_clicked()
  {
      DatabaseControl myDBControl();
      myDBControl.addEmployee();
  }
  </code></pre>
  
  <p>which I expected to just run the addEmployee method I wrote in the header file. However, when I compile, I get the error Error: C2228: left of '.addEmployee' must have class/struct/union</p>
  
  <p>I've looked at other instances of this error and don't really understand exactly what's wrong, and I feel it comes from my misunderstanding of methods in C++, because I know in Java something like this would work without issue (assuming the code in the header is correct which it very well may not be)</p>