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

  • SEARCH
  • Home
  • 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 6717637
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:52:32+00:00 2026-05-26T08:52:32+00:00

please help, im designing a contact book as a project and i’m having compiling

  • 0

please help, im designing a contact book as a project and i’m having compiling the code properly and im getting errors. problem in relation to Address class.. feel free to copy and run code to see what im talking about. thanks in advance

 #include<iostream>
    #include<cstdlib>
    #include<string>
    using namespace std;
    class Address
    {
   private:
      string home;
      string street;
      string apt;
      string city;
      string state;
      string zip;

   public:

      Address();

     string getHome() const;
    string getStreet() const;

      string getApt() const;

      string getCity() const;

      string getState() const;

      string getZip() const;

      void output() const;

      void input();
};

class contact{
private:
    string fn;  
    string ln;
    Address address;
    string email;
    string number;
public:
    void input();
    void output();
    void setname(string f_n, string l_n);
    void setaddress(Address home);
    void setemail(string emaila);
    void setnumber(string num);
    string getname();
    string getAddress();
    string getemail();
    string getnumber();

contact();
contact(string f_n, string l_n, Address home,string emaila,string num);

};
void menu(string opt);
int main(){
        string opt="";
     contact c;
     c.input();
     menu(opt);
     c.output();

cout<<"input up to 10 contacts, type quit to stop if less than 10: "<<endl;

return 0;
}
void menu(string opt){
cout<<"Choose(type) a Menu: search | display all(show) | exit'"<<endl;
cin>>opt;
if(opt=="search")cout<<"write a function that index"<<endl;
else if(opt=="show")cout<<"write a function that display all: "<<endl;
else if(opt=="exit")exit(0);
}
contact::contact(){ 
    fn="";  ln="";  Address address;    email="";   number="";
}
contact::contact(string f_n, string l_n, Address address,string emaila,string num){
fn= f_n; ln= l_n; address ="" ;email= emaila;number= num;
}

void contact::input(){
 for (int i=1; i<=10;i++){//allow 10 contacts
cout<<"fn and ln separate by a space: ";
cin>>fn>>ln;
cout<<"address: ";
Address.input();
cout<<"email: ";
cin>>email;
cout<<"phone number: ";
cin>>number;
}
}
void contact::output(){
cout<<"name: "<<fn<<" "<<ln<<" address "<<Address.output();<<" email: "<<email<<"         digits "<<number<<endl;
}
void contact::setname(string f_n, string l_n){
fn= f_n; ln= l_n;
}

void contact::setemail(string emaila){
email= emaila;
}
void contact::setnumber(string num){
number= num;
}
string contact::getAddress(){
return Address address;
}
string contact::getname(){
return fn, ln;
}

string contact::getemail(){
return email;
}
string contact::getnumber(){
return number;
}
  • 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-26T08:52:33+00:00Added an answer on May 26, 2026 at 8:52 am

    Here’s the output of your code when run through clang (for its far nicer messages).

    λ > clang++ blah.cxx 
    blah.cxx:81:27: error: no viable overloaded '='
    fn= f_n; ln= l_n; address ="" ;email= emaila;number= num;
                      ~~~~~~~ ^~~
    blah.cxx:5:11: note: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'const char [1]' to 'const Address' for 1st argument
    

    The above means you can’t do this: address = "", because you don’t have any implicit conversions from a const char* to an Address object.

    You probably meant this->address = address, since it seems like you’d want to assign the address you received in the constructor?

    As a side note, depending on the compiler you use, you might want to pass Address address by reference like Address& address or const Address& address (indicating you won’t modify the object being referenced) in your function argument list. Though some compilers (if not the most widely used ones) will implement the copy ellision optimization.

    For example your constructor arguments would look like this:

    contact(string f_n, string l_n, const Address& home,string emaila, string num);
    

        class Address
              ^
    blah.cxx:89:8: error: expected unqualified-id
    Address.input();
           ^
    blah.cxx:97:43: error: 'Address' does not refer to a value
    cout<<"name: "<<fn<<" "<<ln<<" address "<<Address.output();<<" email: "<<email<<"         digits "<<number<<endl;
                                              ^
    

    Your member object is called address, not Address. You want to call address.output(), otherwise Address.output() is really trying to call a static function called output from the Address class.


    blah.cxx:97:60: error: expected expression
    cout<<"name: "<<fn<<" "<<ln<<" address "<<Address.output();<<" email: "<<email<<"         digits "<<number<<endl;
    

    Same problem as above, use address.output() since you’re calling the function output() on address.


    blah.cxx:110:8: error: 'Address' does not refer to a value
    return Address address;
           ^
    

    return address; is the correct way to return the address object. return Address address; is nonsense.


    blah.cxx:113:8: warning: expression result unused [-Wunused-value]
    return fn, ln;
           ^~
    1 warning and 5 errors generated.
    

    fn is unused here. Just a warning, but it indicates you either forgot to use it, or it can be removed from your code without harm.

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

Sidebar

Related Questions

A little help please. I am designing a stateless server that will have the
Please help! I'm really at my wits' end. My program is a little personal
Please help! Background info I have a WPF application which accesses a SQL Server
Please help me with a sanity check. Assuming a many-to-many relationship: Post, PostTagAssoc, Tag
Please help, I am stuck here --- irb> a = line of text\n line
Please help! I couldn't figure it out how to map the following situation: I
Please help us settle the controversy of Nearly everything is an object ( an
Please help me convert this line to C#. objManagementBaseObject.SetPropertyValue(hDefKey, CType(&H & Hex(RegistryHive.LocalMachine), Long)) Related
Please help me understand how the process goes. I understand that web browsers contain
Please help to the newbie in WPF! I need to build a TreeView with

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.