How to set up multi source and header files for online compiler?

0 votes
asked Jul 7 by Todd (140 points)

Header File: (In my projects it is listed as "headerSquareCube.h") but it is listed as a project.

//
// fheaderSquareCube.h
//

float funcSquareCube (float, float&);

main function: (In my projects it is listed as "mainSquareCube") and listed as a project.

// mainSquareCube.cpp
//
#include <iostream>
#include <iomanip>

#include "headerSquareCube.h"

using namespace std;

int main()
{
    float input;
    float input_squared;
    float input_cubed;

    cout << "Enter A Value : "; cin >> input;

    input_squared = funcSquareCube(input, input_cubed);

    cout << fixed << setprecision(2);
    cout << "Input Squared : " << setw(6) << input_squared << endl;
    cout << "Input Cubed   : " << setw(6) << input_cubed << endl;

    return (0);
}

called function: (In my projects it is listed as "funcSquareCube") and listed as a project.

//
// funcSquareCube.cpp
//
#include <cmath>

using namespace std;

float funcSquareCube(float x, float& cube)
{
    float square;
    
    square = pow(x, 2.0);
    cube = pow(x, 3.0);
    return (square);
}

What am I missing?

1 Answer

0 votes
answered Jul 8 by Peter Minarik (4,550 points)

You can share a whole project done in Online GDB.

  1. Go to My Projects on the left side panel.
  2. From the Actions select Share/Embed Project.
  3. Copy and share your Share Code.

So it would look something like this: https://onlinegdb.com/rkpBH1mkD

"What am I missing?" - Share your errors

It's best to share any errors you received in your project. For me, things work fine in the above mentioned project.

Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...