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 8477993
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:37:17+00:00 2026-06-10T18:37:17+00:00

Need help, please guide me on this. How to solve the errors as stated

  • 0

Need help, please guide me on this.
How to solve the errors as stated below?

  • 30:24:error:expected ‘)’ before ‘,’ token

  • In member function ‘int Address::compareTo(const Address&)’:

  • 41:26:error:’std::string’ has no member named ‘compareTo’

    #include<iostream>
    using namespace std;

    class Address {
      int    houseNumber;
      string street;
      int    apartmentNumber;
      string city;
      string state;
      string zipCode; // e.g., "47405-1234"
      Address(int houseNumber, 
              string street, 
              // no apartmentNumber  
              string city, 
              string state, 
              string zipCode) { 
        this->houseNumber = houseNumber; 
        this->street = street; 
        this->city = city; 
        this->state = state; 
        this->zipCode = zipCode; 
      } 
      Address(int houseNumber, 
              string street, 
              int apartmentNumber, 
              string city, 
              string state, 
              string zipCode) { 
        this(houseNumber, street, city, state, zipCode);
        this->apartmentNumber = apartmentNumber; 
      } 
      void print(void) {
             std::cout << "Street: " << street << "\nCity: " 
                 << city << "\nState: " << state << "\nPostal Code: " << zipCode;
    }

      int compareTo(const Address &a) { 
        // same conventions as for Strings
        return this->zipCode.compareTo(a); 
      }
    };
  • 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-06-10T18:37:19+00:00Added an answer on June 10, 2026 at 6:37 pm

    The function you’re looking for is compare, not compareTo (Java, C# anyone)?

    Also, note that angle is not declared in your scope. Did you mean:

    return this->zipCode.compare("angel"); 
    

    or did you just omit the variable?

    You also (“should” where applicable):

    • don’t need this->
    • as an alternative to compare you can use == (this returns true for equality)
    • print and compareTo should be marked as const
    • use member initializer lists in the constructors
    • remove the using namespace std; from the header
    • separate the implementations in source files
    • use include guards for headers
    • proper indentation
    • pass string parameters to the constructor by const &…
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Please i need help, this code below works fine on my localhost, php5.3+ but
I need a little help here please.What am trying to do is pull all
Please, I need help with my code: def start(): def start_tkinter(): global main,l main.destroy()
Need some help, please. I have a line of horizontal thumbnails loaded as ONE
Please I need your help with grabbing rows from a table and dynamic text
Please help! I need to produce a Crystal Report with multiple data columns, but
please i need you help with my script.. I'm trying to echo some content
Please I need your help with my script. I'm trying to insert values into
Please i need your help with how to include INDEXES in my tables, i've
Please help me to improve the following script: http://jsfiddle.net/n9BkM/8/ I need the following fucntionality:

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.