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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T08:09:20+00:00 2026-05-30T08:09:20+00:00

I’m having the hardest time with this. I don’t even understand the error messages

  • 0

I’m having the hardest time with this. I don’t even understand the error messages anymore since there’s so many of them. I think there’s a problem with my alphaGreater() class function parameters but who knows. Can anybody get this to sort alphabetically using the bubble sort inside mySort()?

#include <iostream>
#include <fstream>
#include <string>
#include "phoneEntry.h"
using namespace std;

void mySort(PhoneEntry arr[], int size)
{
    bool inOrder = false;
    string temp;
    for (int i = size - 1; i > 0 && !inOrder; i--)
    {
        inOrder = true;
        for (int j = 0; j < i; j++)
        {
            if(arr[j+1].alphaGreater(arr[j]))
            {
                inOrder = false;
                temp = arr[j];
                arr[j] = arr[j + 1];
                arr[j + 1] = temp;
            }
        }
    }
};

int main()
{   
    const int MAXNUM = 500;
    PhoneEntry entry[MAXNUM];
    ifstream filezilla;
    filezilla.open("phone.txt");
    int count = 0;

    if(filezilla)
    {
        while(count < MAXNUM && entry[count].readEntry(filezilla))
        {
            count++;
            mySort(entry, count);
        }   

        for(int i = 0; i < count; i++)
        {
            entry[i].writeEntry(cout) << endl;
        }
    }
    else
    {
        cout << "404" << endl;
    }

    return 0;
}

Phone Entry Header

Phone Number Header

Sorting Text (http://pastebin.com/HE8Rsmbg)

My Errors…

>> g++ sort.cpp -o PhoneSort.exe
object.cpp: In function 'void mySort(PhoneEntry*, int)':
object.cpp:35:29: error: no match for 'operator=' in 'temp = *(arr + ((unsigned
int)(((unsigned int)j) * 20u)))'
object.cpp:35:29: note: candidates are:
c:\mingw\bin\../lib/gcc/mingw32/4.6.1/include/c++/bits/basic_string.h:541:7: not
e: std::basic_string<_CharT, _Traits, _Alloc>& std::basic_string<_CharT, _Traits
, _Alloc>::operator=(const std::basic_string<_CharT, _Traits, _Alloc>&) [with _C
harT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>, st
d::basic_string<_CharT, _Traits, _Alloc> = std::basic_string<char>]
c:\mingw\bin\../lib/gcc/mingw32/4.6.1/include/c++/bits/basic_string.h:541:7: not
e:   no known conversion for argument 1 from 'PhoneEntry' to 'const std::basic_s
tring<char>& {aka const std::basic_string<char>&}'
c:\mingw\bin\../lib/gcc/mingw32/4.6.1/include/c++/bits/basic_string.h:549:7: not
e: std::basic_string<_CharT, _Traits, _Alloc>& std::basic_string<_CharT, _Traits
, _Alloc>::operator=(const _CharT*) [with _CharT = char, _Traits = std::char_tra
its<char>, _Alloc = std::allocator<char>, std::basic_string<_CharT, _Traits, _Al
loc> = std::basic_string<char>]
c:\mingw\bin\../lib/gcc/mingw32/4.6.1/include/c++/bits/basic_string.h:549:7: not
e:   no known conversion for argument 1 from 'PhoneEntry' to 'const char*'
c:\mingw\bin\../lib/gcc/mingw32/4.6.1/include/c++/bits/basic_string.h:560:7: not
e: std::basic_string<_CharT, _Traits, _Alloc>& std::basic_string<_CharT, _Traits
, _Alloc>::operator=(_CharT) [with _CharT = char, _Traits = std::char_traits<cha
r>, _Alloc = std::allocator<char>, std::basic_string<_CharT, _Traits, _Alloc> =
std::basic_string<char>]
c:\mingw\bin\../lib/gcc/mingw32/4.6.1/include/c++/bits/basic_string.h:560:7: not
e:   no known conversion for argument 1 from 'PhoneEntry' to 'char'
object.cpp:37:30: error: no match for 'operator=' in '*(arr + ((((unsigned int)j
) + 1u) * 20u)) = temp'
object.cpp:37:30: note: candidate is:
phoneEntry.h:12:7: note: PhoneEntry& PhoneEntry::operator=(const PhoneEntry&)
phoneEntry.h:12:7: note:   no known conversion for argument 1 from 'std::string
{aka std::basic_string<char>}' to 'const PhoneEntry&'
  • 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-30T08:09:22+00:00Added an answer on May 30, 2026 at 8:09 am

    Your arr parameter holds an array of PhoneEntry values. You attempt to read an entry from that array and store it in a string when you write temp = arr[j]. You can’t assign a PhoneEntry to a string. Change temp to have a type that can hold PhoneEntry values, namely PhoneEntry:

    PhoneEntry temp = arr[j];
    arr[j] = arr[j + 1];
    arr[j + 1] = temp;
    

    Better yet, use the swap function from the <algorithm> header. Remove the temp variable and replace the three lines above with this one:

    std::swap(arr[j], arr[j + 1]);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
this is what i have right now Drawing an RSS feed into the php,
We're building an app, our first using Rails 3, and we're having to build
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
Does anyone know how can I replace this 2 symbol below from the string

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.