0

I have a Strings.h, a Strings.cpp and a main.cpp function for a project I am working on. The compiler is currently giving me the following error which I don't understand why.

Error LNK2019 unresolved external symbol "public: void __thiscall Strings::getType(class std::basic_string,class std::allocator >)" (?getType@Strings@@QAEXV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function _main Project12 c:\Users\dan revie\documents\visual studio 2015\Projects\Project12\main.obj

Strings.h

#ifndef STRINGS_H
#define STRINGS_H
#include <vector>
#include <string>

using namespace std;

//enum stringType { NONE = 0, SINGLEWORD = 1, PALINDROME, WITHDIGITS, OTHERS }; // 1.1

class Strings {

public:
    // public members


    void getType(string phrase); // 1.4
    int getSize(string phrase); // 1.4


    //void checkValid();



private:
    // private members
    string phrase; // 1.2
    int stringSize; // 1.3

    vector<Strings> String_records; //2.1
};

#endif

Strings.cpp

#include "Strings.h"
#include <iostream>



void Strings::getType(string phrase)
{
    cout << "Hello";
    vector <char> palin1;
    vector <char> palin2;
    bool palinSwitch = true;
    // Palindrone Test

    // forward
    for (unsigned int i = 0; i < phrase.size(); ++i)
    {
        palin1.push_back(phrase[i]); 
    }

    // backward
    for (unsigned int i = phrase.size(); i >= 0; --i)
    {
        palin2.push_back(phrase[i]);
    }

    // Comparison for palindrone
    for (unsigned int i = 0; i < phrase.size(); ++i)
    {
        if (palin1[i] != palin2[i])
        {
            cout << "This is not a palindrone" << endl;
            palinSwitch = false;
        }
    }

    if (palinSwitch == false)
    {
        bool phraseSwitch = false;
        for (unsigned int i = 0; i < phrase.size(); ++i)
        {
            // PHRASE CASE-----------------------------------------------------
            if (isspace(phrase[i]))
            {
                // it is a phrase
                for (unsigned int i = 0; i < phrase.size(); ++i)
                {
                    if (isdigit(phrase[i]))
                    {
                        phraseSwitch = true;
                    }
                }

                if (phraseSwitch == true)
                {
                    cout << "This is a phrase with digits" << endl;
                }
                else if (phraseSwitch == false)
                {
                    cout << "This is a phrase without digits" << endl;
                }
            }
            // SINGLE WORD CASE------------------------------------------------
            else // it is a single word
            {
                for (unsigned int i = 0; i < phrase.size(); ++i)
                {
                    if (isdigit(phrase[i]))
                        phraseSwitch = true;
                }
                if (phraseSwitch == true)
                {
                    cout << "This is one word with digits" << endl;
                }
                else if (phraseSwitch == false)
                {
                    cout << "This is one word without digits" << endl;
                }
            }

        }
    }
}

int Strings::getSize(string phrase)
{
    int count = 0;
    for (unsigned int i = 0; i < phrase.size(); ++i)
    {
        if (!isspace(phrase[i]))
            ++count;
    }
    return count;
}

main.cpp

#include "Strings.h"
#include <iostream>

int main()
{
    string phrase;

    Strings s; 

    cout << "Please enter a string to be analyzed: "; 
    cin >> phrase; 

    s.getType(phrase);
    //s.getSize(phrase);

    return 0;
}

If anyone could shed light on this it would be appreciated.

ranu
  • 622
  • 15
  • 25
Daniel R
  • 103
  • 1
  • 5

0 Answers0