Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4026914
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T11:01:53+00:00 2026-05-20T11:01:53+00:00

Okay I need some insight. I am taking a C++ class and am working

  • 0

Okay I need some insight.

I am taking a C++ class and am working on my second project. I am trying to create a list of options that allow you to store emails in a string vector.

Now before taking the time to help me and look at the code I want to point out my problem. I made an object in the file “HughesProject2-1.cpp”:

HughesEmail myhughesEmail();

Well the problem comes right after this when I used this object to run displayList():

myHughesEmail.displayList();

Visual 2010 keeps telling me “error: Expression must have class type”

Now I am using the book as a reference to doing this and they created an object the same way and used it the same way right after. I am confused at what I have wrong as my file is quite different past the basics of using the objects and what is being done. I understand there my be other errors as this is incomplete and I’m still learning, I need to know what is most likely causing me from using the object after I made it. Thanks in advance.

I have three files:

HughesEmail.cpp

// Classes for HughesProject2-1.cpp and HughesEmail.h

// Includes
#include <string>
#include <iostream>
#include <vector>
#include <iomanip>
#include "HughesEmail.h"

// Namespaces
using namespace std;

// Initializing Constructor
HughesEmail::HughesEmail()
{
    vector< string > emailStorage( 100 );
    emailMinimumLength = 9;
    exitOption = 1;
    emailOption = 1;
}

void HughesEmail::displayList()
{
    // Check if exit is set, if not run.
    if ( exitOption == 1 )
    {
    // Email list options
    cout << "Choose from the list of options: \n"
        "1 - Store an email address.\n"
        "2 - Search an email address.\n"
        "3 - List all email adresses.\n"
        "4 - Delete an email address.\n"
        "0 - Exit.\n" << endl;

    while ( emailOption != 0 )
    {
        // Get user input for email list option
        cout << "Option? : ";
        cin >> option;

        switch ( option )
        {
        case '0':
            // set exitOption to 0
            exitOption = 0;
            emailOption = 0;
            break;
        case '1':
            //Input email name
            cout << "Please input email to be stored: " << endl;
            cin >> emailName;
            // run storeEmail
            storeEmail( emailName );
            break;
        case '2':
            // run searchEmail

            break;
        case '3':
            // run listEmail

            break;
        case '4':
            // run deleteEmail

            break;

        //Ignore
        case '\n':
        case '\t':
        case ' ':
            break;

        default:
            cout << "\nPlease choose a valid option." << endl;
            break;
        } // end switch

    } // end while

    } else {

        exitOption = 0;

    } // end else
}


void HughesEmail::storeEmail( string emailName )
{
    // Initialize counter
    int i;
    i = 0;

    // Check if input emailName meets emailMinimumLength
    if( emailName.length() >= emailMinimumLength )
    {

      // if email in vector slot i is less than minimum length, then override with new email.
      if ( emailStorage[ i ].length() < emailMinimumLength )
      {
          emailStorage[ i ] = emailName;
      } else {
          i++;
      } // end else

    } else {
        cout << "Email does not meet the minimum length of: " << emailMinimumLength << " characters." << endl;
    } // end else
}

HughesEmail.h

 // In this project: HughesProject2.h
    // Class header file.

    //Includes
    #include <string>
    #include <iostream>
    #include <vector>

    //Namespaces
    using namespace std;

    class HughesEmail
    {
    public:
        HughesEmail();
        void displayList();
        void storeEmail( string );
        string searchEmail( string );
        string listEmail();
        void deleteEmail();
    private:
        vector< string > emailStorage;
        int emailMinimumLength;
        int emailOption;
        int exitOption;
        char option;
        string emailName;
    };

HughesProject2-1.cpp

// In this project: HughesProject2-1.cpp
// Class creation to store email adresses. Adding, deleting, searching and listing email addresses.

// Includes
#include <string>
#include <iostream>
#include <vector>
#include "HughesEmail.h"

// Namespaces
using namespace std;

int main()
{
    //Create HughesEmail Object
    HughesEmail myHughesEmail();
    myHughesEmail.displayList();

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T11:01:54+00:00Added an answer on May 20, 2026 at 11:01 am

    You’ve run into something called the most vexing parse.

    HughesEmail myHughesEmail();
    

    This line does not construct a new HughesEmail object on the stack. Rather, it declares a function that returns a HughesEmail and takes nothing. You should remove the empty parentheses.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Okay so im working on this php image upload system but for some reason
Okay, so I'm obviously a newbie, but I need some help passing a variable
Ok been working with WPF for a while but I need some help. I
Okay, I am stumped on this one and need some quick help. I have
Okay, so this probably sounds terribly nefarious, but I need such capabilities for my
Okay, here's the scenario. I have a utility that processes tons of records, and
Okay, we know that the following two lines are equivalent - (0 == i)
Okay, I want some jQuery/JavaScript to show an yellow background-color when its checked. I
Okay so i set up this thing so that I can print out page
Okay, newbie multi-threading question: I have a Singleton class. The class has a Static

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.