Find the syntax errors in the definitions of the following classes: a. class AA
ID: 3905673 • Letter: F
Question
Find the syntax errors in the definitions of the following classes:
a. class AA
{
public:
void print ();
int sum ();
AA ();
int AA(int, int);
private:
int x;
int y;
};
b. class BB
{
int one;
int two;
public:
bool equal();
print();
BB(int, int);
}
c. class CC
{
public;
void set(int, int);
void print();
CC();
CC(int, int):
bool CC(int, int):
private:
int u;
int v;
};
Explanation / Answer
Please find the syntax next to the line:
a. class AA
{
public:
void print ();
int sum ();
AA ();
int AA(int, int);//constructor will not have retuen type syntax error
private:
int x;
int y;
};
b. class BB
{
int one;
int two;
public:
bool equal();
print();//function should have a prototype
BB(int, int);
}//here semicolon is not there
c. class CC
{
public;//here syntax error semicoln shouls be replaced with :
void set(int, int);
void print();
CC();
CC(int, int):
bool CC(int, int)://invalid way of delcaring a constructor
private:
int u;
int v;
};
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.