Message from C, C++ discussions
January 2020
— `class base{
private:
base(const base &obj) {}
public:
base(){}
friend base fun(base &obj)
{
base nbj = obj;
return nbj;
}
};
int main(){
base obj;
fun(obj);
return 0;
}`
here copy constructor gets called from inside the friend function so it gets called without any problem
class base{
private:
base(const base &obj) {}
public:
base(){}
friend base fun(base &obj)
{
base nbj = obj;
return nbj;
}
};
int main(){
base obj;
fun(obj);
return 0;
}
— How to format multiline?
— Just use formatting function from telegram. Select a text -> Right click -> Formatting -> Monospace.
— But, when I call the friend funtion and pass by value(copy constructor gets called) then why doesn't that work? class base{
private:
base(const base &obj) {}
public:
base(){}
friend base fun(base obj)
{
base nbj = obj;
return nbj;
}
};
int main(){
base obj;
fun(obj);
return 0;
}
Doesn't call by value happen inside the friend function?
— Does this even work? Copy assignmeny not defined
— No, it doesn't.
— /report
— Reported Sofia to admins.
— Hi I have a question about sockets?
Can i do a program like a calculator on the server that responds with solutions to questions of the client?
— Userbot?
— Yup