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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T15:07:45+00:00 2026-05-12T15:07:45+00:00

I have this class which has a double list template of a struct of

  • 0

I have this class which has a double list template of a struct of two chars and another struct

typedef struct KeyC{
     char K[5];
     char C[9];
} TKeyC;

typedef struct Bin{
     char Car;
     char Cad[9];
     TKeyC *KC;
} TBin;

class Bo {
    private:
        TDoubleList<TBin> *Ent;

    public:
            ...
}

I have a method to create nodes. No problem with this, but when I call other method to modify the direction of the pointer to a new TKeyC struct this simply doesn’t happen.

TNode<TBin> *Aux;
TKeyC *AuxKC=new TKeyC;
Aux->getObj().KC=AuxKC;

Do I have to use a class instead of a struct in this case or is a problem of structs or there is a bug in it?

Update

template <class T>
class TNode
{
    private:
         T TObj;
         TNode<T> *Prev,*Next;

    public:
        TNode();
        ~TNode();
        TNode(T);
        void setObj(T);
        void sPrev(TNode<T>*);
        void sNext(TNode<T>*);
        T getObj();
        TNode<T>* gPrev();
            TNode<T>* gNext();
};

And the method getObj:

template <class T>
T TNode<T>::getObj() {return(TObj);};
  • 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-12T15:07:45+00:00Added an answer on May 12, 2026 at 3:07 pm

    A structure in C++ is a class whose members are all public. If your assignment isn’t changing the value you want it to, then you are not assigning to what you think you are.

    Your getObj() function returns a copy of the structure, not a reference to the original. So you update the value in the copy, and the original remains unchanged.

    Get a reference to your object, either by changing the return type of getObj() to T& or adding another function if you have other code that depends on the behavior.

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

Sidebar

Related Questions

I have a case class which takes a list of functions: case class A(q:Double,
I have a class which looks something like this: public class Test { private
I have a class which is marked with a custom attribute, like this: public
I have this sample text, which is retrieved from the class name on an
I may be going about this backwards... I have a class which is like
I have this class called Table: class Table { public string Name { get
I have this class. public class Foo { public Guid Id { get; set;
This is probably not possible, but I have this class: public class Metadata<DataType> where
I know python functions are virtual by default. Let's say I have this: class
I have this Task model: class Task < ActiveRecord::Base acts_as_tree :order => 'sort_order' end

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.