#struct intlizie isn't working well

17 messages · Page 1 of 1 (latest)

old fox
#

in this code i am trying to intilize this struct :

struct Token{
  TokenType type;//TokenType is an enum
  const std::string& value;
  int line;
};

just like that :

  Token makeToken(TokenType type){
    Token token{type,std::string(start,current),line};//start and current are char pointers
    return token;
  }
``` but the debbuger is showing me that type (the argument) is 19 and line is 1 
But for some reason the line and type (and value) of the token variable is some random numbers
covert kiteBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

rancid hearth
old fox
rancid hearth
old fox
#

yea i think i got it
i would just store std::string dirictly

rancid hearth
#

the way you have it currently is that it just immediately dangles

old fox
#

still the same thing tho

old fox
thin relic
#

The line the debugger is on hasn't been executed yet, you need to step over that line so the one with return is highlighted before taking a look at the token variabl

thin relic
#

it's one of those things you just get used to when debugging

old fox
#

ok thx

#

!solved