by Rashid on
Today paper is 10.30 am
Find out the error(s) in the below code segment. Also describe the reasons of each error, and provide the correct code.
class Employee {
int id;
public:
Employee(int _id){
id=_id;
}
};
int main(){
Employee E[2];
}
int id;
public:
Employee(int _id){
id=_id;
}
};
int main(){
Employee E[2];
}
Consider the following Complex class,
class Complex{
private:
double real, img;
public:
…
};
We want to overload subtraction (-) operator for our Complex class such that we can subtract any double value from our Complex class object using statements given below,
private:
double real, img;
public:
…
};
We want to overload subtraction (-) operator for our Complex class such that we can subtract any double value from our Complex class object using statements given below,
Complex c1;
Complex c2 = 1.546 - c1;
Complex c3 = c1 - 2.456;
Complex c2 = 1.546 - c1;
Complex c3 = c1 - 2.456;
You have to give the C++ code of overloaded subtraction (-) operator to perform these kinds of operations.
When an object of a derived class is declared, it has an anonymous object of its base class
Comments
Post a Comment
Please give us your feedback & help us to improve this site.