C++, I'm stuck with vectors and functions

Well Can I cut in with my owns question?

OK so I have a new question. Unless you know a bit about programming you probably wont be able to help, But you can still say what you think.
I'm trying to make a console program of the math game Suduku, in C++. I have the algorithm wrote out, but then syntax is a problem for me. This is what I have so far:
Code:
//By: Thevil1
#include <iostream>                                                     //line 1
using namespace std;                                                    //line 2
int main()                                                              //line 3

{                                                                       //line 4
    int aa, ab, ac, ad, ae, af, ag, ah, ai,                             //line 5
        ba, bb, bc, bd, be, bf, bg, bh, bi,                             //line 6
        ca, cb, cc, cd, ce, cf, cg, ch, ci,                             //line 7
        da, db, dc, dd, de, df, dg, dh, di,                             //line 8
        ea, eb, ec, ed, ee, ef, eg, eh, ei,                             //line 9
        fa, fb, fc, fd, fe, ff, fg, fh, fi,                             //line 10
        ga, gb, gc, gd, ge, gf, gg, gh, gi,                             //line 11
        ha, hb, hc, hd, he, hf, hg, hh, hi,                             //line 12
        ia, ib, ic, id, ie, iF, ig, ih, ii;                             //line 13
ab = 3; ad = 1; ae = 7; ai = 4;  bd = 9; bf = 8; bg = 6; cc = 7; ce = 2;//line 14
ch = 8; ci = 5; dd = 7; dg = 8; di = 2; ea = 5; ec = 8; ed = 6; ef = 2; //line 15
eg = 7; ei = 1; fa = 1; fc = 2; ff = 5; ga = 7; gb = 8; ge = 4; gg = 3; //line 16
hc = 3; hd = 2; hf = 1; ia = 4; ie = 6; iF = 7; ih = 1;                 //line 17


  
    //board game layout
    cout << "|_1___2___3_|_4___5___6|__7___8___9_|  \n";                //line 18
    cout << "|   |   |   |   |   |   |   |   |   |  \n";                //line 19
    cout << "|___|___|___|___|___|___|___|___|___|a \n";                //line 20
    cout << "|   |   |   |   |   |   |   |   |   |  \n";                //line 21
    cout << "|___|___|___|___|___|___|___|___|___|b \n";                //line 22
    cout << "|   |   |   |   |   |   |   |   |   |  \n";                //line 23
    cout << "|___|___|___|___|___|___|___|___|___|c_\n";                //line 24
    cout << "|   |   |   |   |   |   |   |   |   |  \n";                //line 25
    cout << "|___|___|___|___|___|___|___|___|___|d \n";                //line 26
    cout << "|   |   |   |   |   |   |   |   |   |  \n";                //line 27
    cout << "|___|___|___|___|___|___|___|___|___|e \n";                //line 28
    cout << "|   |   |   |   |   |   |   |   |   |  \n";                //line 29
    cout << "|___|___|___|___|___|___|___|___|___|f_\n";                //line 30
    cout << "|   |   |   |   |   |   |   |   |   |  \n";                //line 31
    cout << "|___|___|___|___|___|___|___|___|___|g \n";                //line 32
    cout << "|   |   |   |   |   |   |   |   |   |  \n";                //line 33
    cout << "|___|___|___|___|___|___|___|___|___|h \n";                //line 34
    cout << "|   |   |   |   |   |   |   |   |   |  \n";                //line 35
    cout << "|___|___|___|___|___|___|___|___|___|i_\n";                //line 36
    cout << endl;                                                       
    
       
system("pause");                                                        //line 37                                  
return 0;                                                               //line 38                         
}                                                                       //line 39
I copied a puzzle from websudoku.com. My problem is How do I get the pre-defined integers (lines 14-17) into their correct place on the bored, an the one that are user defined into their correct places. Then I will just use one big 'if' statement to sum it all up.

NOTE: the board layout goes as follows:
'aa' goes in 1a, 'ab' goes in 2a etc... I tried to make it as simple as I could.
PLEASE HELP! :)
 
NOTE: the board layout goes as follows:
'aa' goes in 1a, 'ab' goes in 2a etc... I tried to make it as simple as I could.
Geez... Go look up arrays! (Specifically, 2D ones!)
 
Not sure about in C++, and if they behave the same way but this is how you would do it in java.

Code:
//java
Vector<datatype> vector_name = new Vector<datatype>();
vector_name.add(new datatype(arg1, arg2, arg3));

So if I were you I'de make sure that my turbine class has a constructor defined (post your turbine.h file so we can help with this).

Then, perhaps something like this will work:
Code:
//c++
Vector <turbine> turb();
turb.push_back(new turbine(arg1, arg2, arg3)); //constructor arguments

or alternatively with code that's a little easier to understand you could use
Code:
//c++
Vector<turbine> turb();
turbine tmp = new turbine(arg1, arg2, arg3); //construstor arguments
turb.push_back(tmp);

Post your turbine.h file and we'll be able to help out more.

Edit: Nvm I see your turbine file now, but not the code of the turbine constructor, just it's declaration. I think the problem may be in there. Keep in mind you can use the constructor to set initial values of your turbines rather than calling gets and sets for each newly created turbine.
 
Back
Top Bottom