D
D
Daniel2018-10-17 05:57:13
C++ / C#
Daniel, 2018-10-17 05:57:13

Does an error occur when creating an instance of a class in a method and returning?

I create an object in a method and return a pointer to it, like this, I hope that I'm doing something wrong.

Socket* Socket::accept() {
            /*    ГДЕ то тут инициализирую   this->address = str_addr; // 127.0.0.1
           */
            return new Socket(client_sock_id);  
  }
  // ВЫЗЫВАЮ ЗДЕСЬ
  Socket *c = s.accept();
// с->getAddress()// выходят русские буквы МММММММММММММММММММММММММ-штук под 100 или больше

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
jcmvbkbc, 2018-10-17
@jcmvbkbc


Socket* Socket::accept() {
            /*    ГДЕ то тут инициализирую   this->address = str_addr; // 127.0.0.1
           */
            return new Socket(client_sock_id);  
  }
  // ВЫЗЫВАЮ ЗДЕСЬ
  Socket *c = s.accept();
// с->getAddress()// выходят русские буквы МММ....-штук под 100 или больше

I hope I'm doing something wrong.

You ask a question about the behavior of the code, but you don't show the code itself. How do we know what kind of Socket class it is, what kind of str_addr it is, and how do you output in the place where Russian letters come out?
Fix this first.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question