1

I have a function where i want to be able return what is printed out so then i can print the output on the page. How will i return both of the string which are outputted within both of those if statements ?

 std::vector<std::string> el;
      split(el,message,boost::is_any_of("\n"));
      std::string a ("");

          for(int i = 0; i < el.size(); i++)
          {
              if(el[i].substr(0,3) == ".X/")
              {
                  DCS_LOG_DEBUG("--------------- Validating .X/ ---------------")
                  std::string str = el[i].substr(3);
                  std::vector<std::string>st;
                  split(st,str,boost::is_any_of("/"));
                  boost::regex const string_matcher(splitMask[0]);
                  if(boost::regex_match(st[0],string_matcher))
                  {
                      a = "Correct Security Instruction";

                  }
                  else
                  {
                      a = "Incorrect Security Instruction" 
                  }

                  boost::regex const string_matcher1(splitMask[1]);
                  if(boost::regex_match(st[1],string_matcher1))
                  {
                     a = "Correct Security screening result" 
                  }
                  else
                  {
                      a = "Incorrect Security screening result" 
                  }


                  return a;

              }

          }

Thankfull for any help :)

4 Answers 4

3

You can return an std::pair of strings, for instance.

Sign up to request clarification or add additional context in comments.

Comments

3

Define a class with two appropriately-named string members and return an instance of that.

Then, start to think about what methods or other data would be useful to have on that class.

Comments

0

You can push the strings in a std::vector that is passed to the function as a reference and later iterate over the vector upon return.

Comments

0

I would return a std::pair of bool values (one to indicate if the instruction is correct, and one to indicate if the screening result is correct), and let the calling code interpret the results.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.