Sesiones de PyR
can anyone plz explain me this program step by step?#include <iostream>
using namespace std;
class MyClass {
    public:
        int var;
        MyClass() { }
        MyClass(int a)
        : var(a) { }
        MyClass operator+(MyClass &obj) {
            MyClass res;
            res.var= this->var+obj.var;
            return res; 
        }
};
int main() {
    MyClass obj1(12), obj2(55);
    MyClass res = obj1+obj2;
    cout << res.var;
}I am not getting the part inside operator+
 0 Votos
 8 Respuestaswhat will be output??
#include <iostream>
using namespace std;
int main(int a)
{
	cout << a << "\n";
	return 0;
}
int main(char *a)
{
	cout << a << endl;
	return 0;
}
int main(int a, int b)
{
	cout << a << " " << b;
	return 0;
}
int main()
{
	main(3);
	main("Subodh");
	main(9, 6);
	return 0;
}
if output is compilation compilation error then how can we overload "main" function in C++
 0 Votos
 5 RespuestasEn tendencia hoy
How create a new language ?
 1 Votes
Beginner question
 0 Votes
I need help to solve this
 0 Votes
Remove
 0 Votes
Project
 0 Votes