//cube.h

#ifndef CUBE_H
#define CUBE_H

class Cube
{
public:
    Cube();
    ~Cube();
    void setSide(double s);
    double getSide();
    double Area();
    double Volume();
    void Properties();
private:
    double Side;
};

#endif 
´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´
#include <iostream>
#include "cube.h"
using namespace std;
Cube::Cube()
{
}

Cube::~Cube()
{
}

void Cube::setSide(double s)
{
    Side = s <= 0 ? 1 : s;
}

double Cube::getSide()
{
    return Side;
}

double Cube::Area()
{
    return 6 * Side * Side;
}

double Cube::Volume()
{
    return Side * Side * Side;
}

void Cube::Properties()
{
    cout << "Characteristics of this cube";
    cout << "\nSide   = " << getSide();
    cout << "\nArea   = " << Area();
    cout << "\nVolume = " << Volume() << "\n\n";
} 
´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´

//main.cpp
#include "cube.h"
using namespace std;
int main()
{
    Cube cube;
    cube.setSide(-12.55);
    cube.Properties();

    Cube de;
    de.setSide(28.15);
    de.Properties();

return 0;
} 

´´´´´´´´´´´´´´´´´´´´´´´
compiling with g++ main.cpp -0 main

I wish to (a) reinforce Chris's comment you have posted 18 and should have figured that out.


Use the advanced button and enclose you code. Use the # button.

Solution to the problem is that you missed out a : on the definition line
properties

General Note:

I believe that this forum needs a "how to debug problems" thread with the basics of how to split a problem down, how to get the compiler to work for you, rather than against you etc. The stuff that I seem to have to explain to the novices time and time again,
[particularly those that have come from interpreted languages -- because the mind set is different.]

: is not problem

start quote:

//cube.h

#ifndef CUBE_H
#define CUBE_H

class Cube
{
public:
    Cube();
    ~Cube();
    void setSide(double s);
    double getSide();
    double Area();
    double Volume();
    void Properties();
private:
    double Side;
};

#endif 
´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´
#include <iostream>
#include "cube.h"
using namespace std;
Cube::Cube()
{
}

Cube::~Cube()
{
}

void Cube::setSide(double s)
{
    Side = s <= 0 ? 1 : s;
}

double Cube::getSide()
{
    return Side;
}

double Cube::Area()
{
    return 6 * Side * Side;
}

double Cube::Volume()
{
    return Side * Side * Side;
}

void Cube:: Properties()
{
    cout << "Characteristics of this cube";
    cout << "\nSide   = " << getSide();
    cout << "\nArea   = " << Area();
    cout << "\nVolume = " << Volume() << "\n\n";
} 
´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´

//main.cpp
#include "cube.h"
using namespace std;
int main()
{
    Cube cube;
    cube.setSide(-12.55);
    cube.Properties();

    Cube de;
    de.setSide(28.15);
    de.Properties();

return 0;
} 

compiling with g++ main.cpp -0 main

i do not know m writing double dots Properties but it is coming funny ::Properties

PLEASE READ THE POSTS ABOVE

THAT MEANS DO NOT POST CODE UNLESS IT IS IN code BLOCKS.

Your code works fine. BUT you have the wrong g++ line (since -O is
optimize) and you really wanted -o.

Otherwise you will have to post your output and you code in CODE blocks.

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.