Question: what's wrong with programming? #include #include using namspace std; struct names { string first; string last; }; int main() { names.customer = Smith, Orley; cout
what's wrong with programming?
#include
#include
using namspace std;
struct names {
string first;
string last;
};
int main() {
names.customer = "Smith", "Orley";
cout << name.first << endl;
cout << names.last << endl;
return 0;
}
-------------------------
struct ThreeVals {
int a, b, c;
};
int main () {
TwoVals s, *sptr = nullptr;
*sptr.a = 1;
return 0;
}
--------------------------
struct Values { string name;
int age;
}
-------------------
#include
using namespace std;
class DumBell;
{
int wekght;
public:
void setWeight(int);
}
void setWeight(int w)
{
Weight = w;
}
int main()
{
DumBell bar;
DumBell(200);
cout << "The weight is " << bar.weight << endl;
return 0;
}
--------------------
class Change
{
public:
int pennies;
int nickels;
int dimes;
int quarters;
Change()
{
pennies = nickels = dimes = quarters = 0;
}
Change(int p = 100; int n = 50, d = 50, q = 25);
};
void Change::Change(int p, int n , d, q)
{
pennies = p;
nickels = n;
dimes = d;
quarters = q;
}
------------------
class Box
{
private:
double width;
double length;
double height;
public:
Box(double w, l, h)
{
width = w; length = l; height = h;
}
Box(Box b) // Copy constructor
{
width = b.width;
length = b.length;
height = b.height;
... Other member functions follow ...
};
---------------------
class Circle
{
private:
double diameter;
int centerX;
int centerY;
public:
Circle(double d, int x, int y)
{
diameter = d; centerX = x; centerY = y;
}
// Overloaded = operator
void Circle = (Circle &right)
{
diameter = right.diameter;
centerX = right.centerX;
centerY = right.centerY;
}
... Other member functions follow ...
};
-----------------
class Box
{
private:
double width;
double length;
double height;
public:
Box(double w, l, h)
{
width = w; length = l; height = h;
}
// Overloaded prefix ++ operator
void operator++()
{ ++width; ++length; }
// Overloaded postfix ++ operator
void operator++()
{ width++; length++; }
... Other member functions follow ...
};
-----------------
class Car, public Vehicle
{
public:
Car();
~Car();
protected:
int passengers;
}
---------------
Class Table : public Furniture
{
protected:
int numSeats;
public:
Table (int n) : Furniture (numSeats)
{
numSeats = n;
}
~Table();
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
