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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:25:08+00:00 2026-06-04T04:25:08+00:00

I have a string class in my c++ project. I have to use double

  • 0

I have a string class in my c++ project. I have to use double linked list and make my own string class. In my string class I have to overload <, > and == operators. Actually I did this. But in my other class I have a listing function which compares my string classes. In this comparison I had “taking address of temporary” error.

Here is my string class:

#include "String.h"

String::String(int coming)
{
   x=coming;
}

int  String::getX()
{
    return x;
}

String String::operator==(String *taken)
{
    return String (x==taken->x);
}

and here is my listing method:

void myclass::list(String *taken)
{
    otherclass *temp=head;

    while(temp!=NULL)
    {
        if(&temp->get_string()==taken)//where i get error message.
            cout<<temp<<endl;
        temp=temp->get_nextnode();
    }
}
  • 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-04T04:25:09+00:00Added an answer on June 4, 2026 at 4:25 am

    The compiler is telling you precisely the problem: you cannot take the address of a temporary object. temp->get_string() is a temporary object1, and you are trying to take its address.

    I’m not really sure what your aim is here, so I can’t suggest a fix. But I would strongly suggest that defining String::operator== to take a pointer as the right-hand side will lead to confusion. And having it return another String makes little sense either; normally one would expect == to evaluate to a boolean value.


    1. Well, presumably. You haven’t shown the declaration of get_string().

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

Sidebar

Related Questions

I have 2 classes with this structure: class ClassA { String typeA; List<String> valuesA;
can you please help me with this issue the String class does not have
I have the following class structure: class Organization { string Name; List<User> users; List<Organization>
I have a class with 2 strings and 1 double (amount). class Donator string
i have a c++ project on eclipse and i can to use the string
Suppose I have string Name and Image Photo as properties of a class in
I have two models: User (email:string) Profile (name:string) class User < ActiveRecord::Base has_one :profile
I want to have a string variable for a PHP class, which would be
I have added the following method in my User Domain class String getNameAttribute(){ return
I have a class structure like: abstract class A { String a; } class

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.