Errors

0 Brayden Mossey · September 19, 2016
Hello,
I have a few errors I can't figure out. It's just a simple console app that scrambles a puzzle for me. Help is appreciated! :D
main.cpp:
#include <iostream>
#include "MinxScrambler.h"

using namespace std;

int main()
{
    //init variables
    string scrambleType;
    int moveNum;
    string run = "yes";
    //info
    cout << "---------------------------" << endl;
    cout << "Kilominx/Megaminx Scrambler" << endl;
    cout << "          BM vA01          " << endl;
    cout << "---------------------------" << endl;
    //input
    cout << "Scramble Type (normal, random, WCA): ";
    cin >> scrambleType;

    if(scrambleType == "WCA"){

        moveNum = 25;

    }else if(scrambleType == "normal" || scrambleType == "random"){

        cout << "\nScramble length: ";
        cin >> moveNum;

    }else{

        cout << "Invalid scramble type.\n";

    }
    //scramble process
    MinxScrambler scrambler(scrambleType, moveNum);

    for(int x; x < moveNum; x++){

            cout << scrambler.scramble[x] << endl;

    }

}


MinxScrambler.cpp:
#include <iostream>
#include "MinxScrambler.h"
#include <stdlib.h>
#include <time.h>

MinxScrambler::MinxScrambler(string getScrambleType, int getMoveNum)
{
    //int variables
    possMoves[18] = ["R","U","L","F","D","B","R'","U'","L'","F'","D'","B'","R2","U2","L2","F2","D2","B2"];

    string scrambleType = getScrambleType;
    int moveNum = getMoveNum;

}

string[] MinxScrambler::scramble()
{
    //random scramble
    if(scrambleType == "random"){

        string scrambleOut[moveNum];

        for(int counter; counter < moveNum; counter++){

            srand (time(0));

            x = rand() % 18;

            scrambleOut[counter] = possMoves[x];

        }

    }

    return scrambleOut;

}

MinxScrambler.h:
#ifndef MINXSCRAMBLER_H
#define MINXSCRAMBLER_H


class MinxScrambler
{
    public:

        MinxScrambler(string, int); //This line is where I have an error
        string[] scramble();

    protected:

    private:
};

#endif // MINXSCRAMBLER_H

Errors:
||=== Build: Debug in KilominxScrambler (compiler: GNU GCC Compiler) ===|
C:\Users\Mossey\Documents\KilominxScrambler\MinxScrambler.h|9|error: expected ')' before ',' token|
C:\Users\Mossey\Documents\KilominxScrambler\MinxScrambler.h|10|error: 'string' does not name a type|
C:\Users\Mossey\Documents\KilominxScrambler\main.cpp||In function 'int main()':|
C:\Users\Mossey\Documents\KilominxScrambler\main.cpp|36|error: no matching function for call to 'MinxScrambler::MinxScrambler(std::string&, int&)'|
C:\Users\Mossey\Documents\KilominxScrambler\main.cpp|36|note: candidates are:|
C:\Users\Mossey\Documents\KilominxScrambler\MinxScrambler.h|5|note: MinxScrambler::MinxScrambler()|
C:\Users\Mossey\Documents\KilominxScrambler\MinxScrambler.h|5|note:   candidate expects 0 arguments, 2 provided|
C:\Users\Mossey\Documents\KilominxScrambler\MinxScrambler.h|5|note: MinxScrambler::MinxScrambler(const MinxScrambler&)|
C:\Users\Mossey\Documents\KilominxScrambler\MinxScrambler.h|5|note:   candidate expects 1 argument, 2 provided|
C:\Users\Mossey\Documents\KilominxScrambler\main.cpp|40|error: 'class MinxScrambler' has no member named 'scramble'|
||=== Build failed: 4 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|

Post a Reply

Replies

Oldest  Newest  Rating
0 Brayden Mossey · September 28, 2016
I commented in the code, the header file
0 Ryan Carr · December 22, 2016
The first issue that pops out at me is in MinxScrambler.h

In your declaration of Public functions you don't have a return type for MinxScrambler. Looking back at the CPP file it is supposed to return an array of strings.


string[] MinxScrambler(string, int); // This change should resolve all of your errors. Your declarations must match definitions.
  • 1

C++

130,881 followers
About

Used in many types of software including music players, video games, and many large scale applications.

Links
Moderators
Bucky Roberts Administrator