Ikd what the error is telling me as when it compiles, no red lines appear. Plz help me >_< !
thanx in advance

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

    using namespace std;

    #include "Shapes.h"
    #include "ShapeFeatures.h"

    int main()

        cout << "\n\n\n";
        return 0;
    }

    //Shapes.h

    #pragma once

    class Shapes 
    {
    public:
        void square();
        void triangle();
        void circle();

    private:
        ShapeFeatures me;
    };

    void Shapes::square()
    {
        me.getSquareArea();
    }

    void Shapes::triangle()
    {
        me.getTriangleArea();
    }

    void Shapes::circle()
    {
        me.getCircleArea();
    }

    ///ShapeFeatures.h
    #pragma once

    class ShapeFeatures
    {
    public:
        void getSquareArea();
        void getTriangleArea();
        void getCircleArea();
    private:
        int length;
        int base;
        int height;
        double radius;
        double pi = 3.14159;
        double area;
    };

    void ShapeFeatures::getSquareArea()
    {
        area = length*length;
        cout << area << endl;
    }

    void ShapeFeatures::getTriangleArea()
    {
        area = (base * height) / 2;
        cout << area << endl;
    }

    void ShapeFeatures::getCircleArea()
    {
        area = pi * radius * radius;
        cout << area << endl;
    }

Recommended Answers

All 2 Replies

Code is code, but when asking a question try English or your native tongue. I looked up https://www.google.com/search?q=ikd and can't tell what you meant there.

What error? I can't see what error and would have to guess which compiler you are using.

Fill in the blanks on your post.

I looked up https://www.google.com/search?q=ikd and can't tell what you meant there.

Wow, one of those cases where your mind subliminally reorders the letters. Didn't even notice "ikd". I read it as "idk" / "I don't know".

Ikd what the error is telling me as when it compiles, no red lines appear.

"Red lines" may or may not mean anything. Compilers/setups vary. What shows up in red on your compiler might not show up in red on mine, so you should quote the actual output. As far as errors go, the code seems fine if you stick it one file, but since you have them in separate files, I'm thinking you need the following in Shapes.h...

#include "ShapeFeatures.h"

and the following in ShapeFeatures.h...

#include <iostream>
using namespace std;

You have it in your main file, but since these are classes in separate files and Shapes refers to ShapeFeatures, so it needs to include it, and ShapeFeatures uses cout from iostream, so it needs have those lines in there. Sticking them in their own files means they should compile independently from your main file.

commented: I had to look up idk, "I know dude"? +11
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.