-
Don't understand this
Code:
(a) Is/Are there error(s) with the following class definition and/or object creation? If no, provide code to create ONE object. If yes, please provide your explanation for credit.
#include <iostream>
using namespace std;
// For all classes, the negativity of the fraction will apply
// to the numerator
class FractionA {
public:
int n;
int d;
};
int main( void ) {
FractionA frA; // Line 1 : POSSIBLE CODE TO CREATE OBJECT
return 0;
}
What does it mean by "Provide code to create ONE object?"
Thanks.
-
You've created the object successfully. What else do you need?
Yes, class will be created without any errors. In main, you've successfully created the object as it'll call compiler default constructor.
-
Yes, but the question asks if there isn't any errors in the provided code (This code was already given) then I should fill in code to create an object. Is there an object already?
-
I think you should read classes first.
Yes, there is an object in your main(). Try to figure that out. I gave you a clear hint. Not only hint but the exact thing :-)
-
Oh sorry, I didn't realize that... Yes, frA is an object but why is it asking me to create an object if there already is one?
-
So, create one more if you want to and if it's desired by the user. :-)
-
Yes, I can do that, but the question specifically says "one object". I think this is just a mistake by my instructor. Thanks for your help. :)