I created a class to display a string on the terminal, but in addition to displaying the string , also displays the following message: "segmentation failure". I debugged with GDB, but I could not resolve the error. Here is the code below:
#ifndef CONNECTION_H
#define CONNECTION_H
#include<string>
#include<iostream>
using std::string;
class Connection {
public:
Connection();
~Connection();
string conexao;
string getConexao();
};
#endif // CONNECTION_H
#include"teste.h"
Connection::Connection()
{
conexao = "sete de setembro";
}
string Connection::getConexao()
{
std::cout << conexao << std::endl;
}
Connection::~Connection()
{
}
#include "teste.h"
int main(void)
{
Connection con;
con.getConexao();
return 0;
}