1
I am programming a code in Qt(C++) and I need to take values from the client class in the menu class (which I do not inherit from client) and concatenate into a string to print on the screen. follows the code:
cliente* cl = new cliente();
Later in the code I set values for the customer and then arrived at the part that is not working:
string g = "Dados do cliente: \n Nome: " + cl->getNome() + "\n Email: " + cl->getEmail() + " Telefone: " + cl->getTelefone() + "\n Endereço: " + cl->getEndereco() + "\n Carro : " + cl->getCarro() + ", " + cl->getAnoCarro() + " Placa: " + cl->getPlaca() + "\n";
The error is Segmentation fault. The way my getters is this for everyone(are all string):
const string &cliente::getPlaca() const {return placa;}
Does anyone have any idea how to fix?
All methods are strings ? Including
getTelefone
? You can put a Minimum, Complete and Verifiable Example of the problem ?– Isac
Yes, all are string, converted all to string to save.
– Lucas Toledo
An example: I have the client class, then in the menu class I imported client. h, and I created a new client(). At one point I set values for this client of mine, and I ran into this problem: I can’t format a string using client data, from segmentation failure.
– Lucas Toledo
But it makes a mistake to compile ? Or just from the error to run ?
– Isac
Just running really, compile normal
– Lucas Toledo
You can put a Minimum, Complete and Verifiable example of the problem ?
– Isac