I'm facing with a "Memory fault" (QNX) when calling to:
std::string set_name( std::string name )
{
this->name = name;
// return this->string; // commented
}
source code: test.cc
#include <iostream>
#include <string>
class Base{
public:
Base()
{
std::cout << multiply( 100, 200 ) << std::endl;
std::cout << set_name( "set_name" ) << std::endl;
}
std::string set_name( std::string name )
{
this->name = name;
// return this->string; // commented
}
int multiply( int x, int y )
{
ret = x * y;
// return ret; // commented
}
private:
std::string name;
int ret;
};
Base base;
int main(int argc, char** argv)
{
std::cout << "exit" << std::endl;
}
Compiled: Makefile
all:
g++ test.cc -std=c++11 -o test
Result:
// 20000
// ╚Z шГь HН
User contributions licensed under CC BY-SA 3.0