Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

help

Name: curry 2011-02-11 5:29

need help

create a structure named Shirt that has the public data members CollarSize and SleeveLength. Create a structure named Pants that has the public data members waistSize and inSeam. Write a program that declares one object of each type Shirt and Pants and assigns values to the objects' data fields. write two overloaded functions named displayClothingFat(). One version of the function takes a Shirt object as a parameter; the other version takes a Pants object. Each version displays the facts about the piece of clothing. Your main() funcition should demonstrate that you can call displayClothingFacts() with either type of clothing.


here is what i have it does not compile because i am complete noob

#include <iostream>
#include <sstream>

#include <iomanip>


using std::cout;
using std::cin;
using std::endl;

 struct Shirt
{
    double collarSize;
    double sleeveLenth;

};


 struct Pants
{
    double waistSize;
    double inSeam;

};



int main()
{
    Shirt b1;
        Pants b2;
    b1.collarSize;
    b1.sleeveLenth;
    b2.inSeam;
    b2.waistSize;

          void displayClothingFacts(b1);

    void displayClothingFacts(b2);
}

Name: Anonymous 2011-02-11 5:31

[code] tags please!

Name: Anonymous 2011-02-11 5:37

sorry this is my first time using this

Name: Anonymous 2011-02-11 5:39

>>1
No homework help.

Name: Anonymous 2011-02-11 6:12

#include <stdlib.h>
#include <stdio.h>

struct Clothing {
    virtual void displayClothingFacts() = 0;
};

struct Shirt : public Clothing
{
    double collarSize;
    double sleeveLength;
    void displayClothingFacts() {
        printf("Shirt [Collar size: %7.2f; sleeveLength: %7.2f]\n", collarSize, sleeveLength);
    }
};

struct Pants : public Clothing
{
    double waistSize;
    double inSeam;
    void displayClothingFacts() {
        printf("Pantsu [Waist size: %7.2f; In seam: %7.2f]\n", waistSize, inSeam);
    }
};

// as you can see, this works regardless of whether a Shirt or Pants was
// passed as an argument
void display(struct Clothing &c) {
    c.displayClothingFacts();
}

int main()
{
    struct Shirt b1;
    struct Pants b2;
    b1.collarSize = 3;
    b1.sleeveLength = 4;
    b2.inSeam = 5;
    b2.waistSize = 6;
   
    // I can call it directly like this
    b1.displayClothingFacts();
    b2.displayClothingFacts();
   
    // or like this
    display(b1);
    display(b2);
   
    return 0;
}

Name: Anonymous 2011-02-11 6:36

>>5
[u]mailto: noko[u]

Name: Anonymous 2011-02-11 7:39

>>6
lol yhbt``faggot''

Name: noko 2011-02-11 8:42

>>6
noko is my favourite sextoy

Name: Anonymous 2011-02-11 12:38

32 GET

Name: Anonymous 2011-02-12 8:33

JACKSON 5 * 2 GET

Name: Anonymous 2011-02-12 13:50

No dubs for you get

Don't change these.
Name: Email:
Entire Thread Thread List