#include <iostream>
#include <string>
struct Person
{
std::string name;
std::string address;
Person (std::string n, std::string a)
{
name = n;
address = a;
}
std::string get_name() { return name; }
std::string get_address() { return address; }
};
int main()
{
const Person p ("User", "UserAddr");
std::cout << p.get_name() << " " << p.get_address() << std::endl;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3RyaW5nPgoKc3RydWN0IFBlcnNvbgp7CiAgICAgICAgc3RkOjpzdHJpbmcgbmFtZTsKICAgICAgICBzdGQ6OnN0cmluZyBhZGRyZXNzOwoKICAgICAgICBQZXJzb24gKHN0ZDo6c3RyaW5nIG4sIHN0ZDo6c3RyaW5nIGEpCiAgICAgICAgewogICAgICAgICAgICAgICAgbmFtZSA9IG47CiAgICAgICAgICAgICAgICBhZGRyZXNzID0gYTsKICAgICAgICB9CiAgICAgICAgc3RkOjpzdHJpbmcgZ2V0X25hbWUoKSB7IHJldHVybiBuYW1lOyB9CiAgICAgICAgc3RkOjpzdHJpbmcgZ2V0X2FkZHJlc3MoKSB7IHJldHVybiBhZGRyZXNzOyB9Cn07CgoKCmludCBtYWluKCkKewogICAgICAgIGNvbnN0IFBlcnNvbiBwICgiVXNlciIsICJVc2VyQWRkciIpOwoKICAgICAgICBzdGQ6OmNvdXQgPDwgcC5nZXRfbmFtZSgpIDw8ICIgIiA8PCBwLmdldF9hZGRyZXNzKCkgPDwgc3RkOjplbmRsOwp9Cgo=
prog.cpp: In function 'int main()':
prog.cpp:24:33: error: passing 'const Person' as 'this' argument discards qualifiers [-fpermissive]
std::cout << p.get_name() << " " << p.get_address() << std::endl;
^
prog.cpp:14:21: note: in call to 'std::string Person::get_name()'
std::string get_name() { return name; }
^
prog.cpp:24:59: error: passing 'const Person' as 'this' argument discards qualifiers [-fpermissive]
std::cout << p.get_name() << " " << p.get_address() << std::endl;
^
prog.cpp:15:21: note: in call to 'std::string Person::get_address()'
std::string get_address() { return address; }
^