Sesiones de PyR
What is myClass myObj ?
0 Votos
2 Respuestascan 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 RespuestasWhy we use class?
0 Votos
1 Respuestacan someone please explain why this code keeps telling me complication error instead of outputting the value of speed.
#include <iostream>
using namespace std;
class myClass {
public:
void setcarspeed (int a){
speed=a;
}
int getcarspeed(){
return speed;
}
private:
int speed;
};
int main() {
myClass obj;
obj.setcarspeed (40);
cout<<obj.getcarspeed ;
return 0;
}
2 Votos
3 RespuestasPublic, static and void
0 Votos
2 Respuestaspublic class Vehicle {
int maxSpeed;
int wheels;
String color;
double fuelCapacity;
void horn() {
System.out.println("Beep!");
}
}
class MyClass {
public static void main(String[ ] args) {
Vehicle v1 = new Vehicle();
Vehicle v2 = new Vehicle();
v1.color = "red";
v2.horn();
System.out.println(v1);
}
}
Explain its outcome. I am unable to get the last line of outcome.
-1 Voto
2 Respuestasjava learning
0 Votos
1 RespuestaEn tendencia hoy
Someone can help me
2 Votes
What's wrong with this?
2 Votes
HTML community, HELP!!
1 Votes
X velocity
0 Votes
I am a super beginner
0 Votes
Files not linking in C++
0 Votes
Web Dev
0 Votes
How this program executes?
0 Votes