Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C++ visual studio The errors are 1)identifier \"a\" is undefined 2)expected a de

ID: 3645407 • Letter: C

Question

C++ visual studio

The errors are
1)identifier "a" is undefined
2)expected a declaration


#include "stdafx.h"
#include <iostream>
#include <windows.h>


class Circle
{
float r;
Circle()
{
r=0;
}
Circle(float x)
{
r=x;
}
float Area()
{
return 4.3*r*r;
}
}
float Area()
{
return a*a;
}
}
class Rect
{
float l,b;
Rect()
{
l=0;
b=0;
}
Rect(float x, float y)
{
l=x;
b=y;
}
float Area()
{
return l*b;
}
}
void main()
{
clrscr();
Circle c(4);
cout << "Area of circle is " << c.Area();
Rect r(3,6)
cout << "Area of Rectangle is" << r.Area();
getch();
}

Explanation / Answer


#include "stdafx.h"
#include <iostream>
#include <windows.h>


class Circle
{
float r;
Circle()
{
r=0;
}
Circle(float x)
{
r=x;
}
float Area()
{
return 4.3*r*r;
}
}

class Rect

{

float l,b;
Rect()
{
l=0;
b=0;
}
Rect(float x, float y)
{
l=x;
b=y;
}
float Area()
{
return l*b;
}
}
void main()
{
clrscr();
Circle c(4);
cout << "Area of circle is " << c.Area();
Rect r(3,6)
cout << "Area of Rectangle is" << r.Area();
getch();
}

I have modified your code. Now it should work.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote