Help making a function

Hi, I want to move a large chunk from main to a different CPP file, and I literally have been trying to do this for hours with no luck.
File1 (with main)
http://pastebin.com/Np6cHJ0V

File2 (where I want it to be)
http://pastebin.com/DdcMjsNt


Header file:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// Author: Chris Christoff
// Current Build: 4.2.3
// Last build time: 8:55 A.M/ 6/12/2012

class quadratic
{
public:
    struct fStruct
    {
        double coeffs[3];	//a, b, c coefficients
    };

    struct rootStruct
    {
        double roots[2];    //room for two roots
    };

public:
    quadratic();
    fStruct readCoeffs();
    double discr(fStruct);
    double f(fStruct, double);
    double bisect(double, double, double, fStruct, bool&);
    void toFile(fStruct, rootStruct);
    void toScreen(fStruct);
    void linear(fStruct, double);
};


I want to move everything from if(fVars.coeffs[0]==0.0) to brace before return 0; the nonmain file.

I have literally tried this for hours now. Please help me.
Last edited on
Where into the implementation do you want to move it? What method is that code meant to go into?
@Zhuge: I want it to go into the second file. The CPP without the main. Anywhere in it is fine.
Last edited on
Um...ok.

Make a new method (name it for whatever that code does). Cut and paste the code in, changing all references to fVars to this, take any variables used outside the cut code and pass them into the method as parameters, move any variables used only inside the cut code to be local to the method, and then edit main to call fVars.func(...).
Topic archived. No new replies allowed.